Created
May 9, 2017 07:29
-
-
Save mydreambei-ai/36efc34b5860b71c70809e74b43652de to your computer and use it in GitHub Desktop.
three useful sed function
This file contains hidden or 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
function join_lines() | |
{ | |
local delim=${1:-,} | |
sed 'H;$!d;{x;s/\n/'$delim'/g;s/'$delim'//}' | |
} | |
function reverse_lines() | |
{ | |
sed '1!G;h;$!d' | |
} | |
function print_line_number() | |
{ | |
local delim=${1:-'\t'} | |
sed = |sed 'N;s/\n/'$delim'/' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment