Convert rows into space-delimited line and vice versa
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.
ankit$ cat intput.txt
shah
is
my
name
I
am
awesome
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
how
are
you
doing
Comments
Post a Comment