Skip to content

Instantly share code, notes, and snippets.

@mfdj
Last active August 29, 2015 13:57
Show Gist options
  • Save mfdj/9726938 to your computer and use it in GitHub Desktop.
Save mfdj/9726938 to your computer and use it in GitHub Desktop.
view $PATH (or any colon separated string) as a readable multiline output — tested on OSX bash
##### first attempt
# one-liner
echo $PATH | sed -e "s~:~\\`echo -e '\n\r'`~g"
# bash function
sep2ln()
{
local INPUT=$1
local SEPARATOR=$2
echo "$INPUT" | sed -e "s~${SEPARATOR}~\\`echo -e '\n\r'`~g"
}
sep2ln $PATH :
##### cleaner
# one-liner
echo $PATH | sed -e s~:~'\'$'\n'~g
# ignore the weird color problem;
# i think githubs syntax parser is getting confused
# bash function
sep2ln()
{
local INPUT=$1
local SEPARATOR=$2
echo "$INPUT" | sed -e "s~$SEPARATOR~"'\'$'\n'~g
}
sep2ln $PATH :
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment