I’ve seen it being done using sed (if you’d be so kind to write how to do it in sed and explain the regex behind it, I will appreciate it too), but I’d like to know how to do it using tr.
My idea was: cat file|tr -d ^'\n' or ^\n, but the first one deleted every ‘\n’, the second one none.
>Solution :
tr operates on streams of characters, not streams of lines (which is the default for sed and awk and whatnot). The -d flag deletes any of the characters in the character list. tr -d '\n' will delete all the newlines in the stream.
I’m not sure myself if you can delete empty lines using tr.
To use sed sed '/^$/d'. ^ matches front of line. $ matches end of line d says you want sed to delete anything that matches that. However, this type of question has been answered much more comprehensively elsewhere so I’d go back to google and find a comprehensive sed or unix tutorial.