Recently, I look for scripts to take this:
This;
Is;
First;
Line;
and make it like:
This Is First Line
Neither awk nor sed, but how about tr
instead:
printf 'This;\nIs;\nFirst;\nLine;\n' |
tr -s ';[:space:]' '[ *]'
Output: This is First Line
Your example shows spaces between fields, but you mention "CSV", which means Comma Seperated Values... I've used spaces. Just change / /
to /,/
if you want commas.
Input file contains:
This;
Is;
First;
Line;
This;
Is;
Second;
Line;
The script:
sed -nr 'N; N; N; s/;\n/ /g; s/;$//p' file
Output:
This Is First Line
This Is Second Line