While dealing with text processing jobs we would like to convert a selection of rows separated by \n and convert it to space delimited single line.
We will do this with 'tr' - unix tool that translates, deletes, squeezes characters from standard input and writes the same to standard output. "Awk" is a powerful tool used to perform pattern scannind and processing language and it is one of the important commands, a powerful linux user should be aware of its usage.
To convert rows into a space-delimited line and save to a file:
ankit$ cat intput.txt
ankit shah is my name I am awesome$ cat input.txt | tr "\n" " " | tee output.log
To convert spaces to line break (newline) and save to a file:
Hi how are you doing$ cat intput.txt
Hised -e 's/\s\+/\n/g' input.txt | tee output.txt