I have this text file :
z1 x2 c3 v4 b5 n6 m7 a8
and i want to reformat it to:
z1
x2
c3
v4
b5
n6
m7
a8
in the Linux Terminal . How can I do this?
CodePudding user response:
Replace spaces with newlines using sed
sed 's/ /\n/g' my_file > my_file_reformatted
You can find the syntax of sed
on the manual page, but essentially you put the character string you want to replace between the first pair of /
, and the string to replace it with between the second one.
You also don't nessesarily need to use /
as the delimiter, it could be any other character.
CodePudding user response:
To replace all whitespace with newlines, try
tr -s ' \t' '\n' <file >newfile