Created
November 3, 2018 10:24
-
-
Save agile6v/6cc97177ede8a32ca4ed36f668659451 to your computer and use it in GitHub Desktop.
Replace all newline with a comma except the last line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sed -n '1h;1!H;${g;s/\n/,/g;p;}' | |
For example: | |
ip a | grep inet | grep -v inet6 |sed 's/^[ \t]*//g' | cut -d ' ' -f2 | sed -n '1h;1!H;${g;s/\n/,/g;p;}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment