Search code examples
unixls

unix script - delimit output but character other than \n


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