unix script - delimit output but character other than \n
Question
What's a simple way (e.g. no perl) to turn the output of (e.g.) ls into ":"-delimited instead of "\n"-delimited?
I'm hoping for a sed or possibly awk short one-liner, I couldn't figure out how to get those to treat \n
as a character that wasn't a line-delimiter though.
I know Perl regexes provide this via an option, I think /m or /s or something. Which one is it?
Solution
ls | tr "\n" :
ls | awk -vORS=: 1
OTHER TIPS
maybe you can try to use tr, I think it is one char only.
ls | tr '\n' '+'
have you looked at the most venerable tr ?
ls | tr "\n" "."
if I remember well.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow