-1

I have a file where character are in the type abcd abcd abcd abcd but my client wants them in the format as

abcd
abcd
abcd
abcd
Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
  • I tried to add some formatting to your post, but please take a look and see if it's right. See the [formatting help](https://unix.stackexchange.com/help/formatting) if needed. – Jeff Schaller Jun 08 '17 at 15:23
  • 1
    Also, a more complete/thorough example of the contents would help Answerers give you something useful for your case. How should the transformation happen? – Jeff Schaller Jun 08 '17 at 15:24
  • 1
    `sed 's/[[:blank:]]/\n/g' file` – RomanPerekhrest Jun 08 '17 at 15:24
  • 1
    Are the "fields" always separated by a space or tab? If a space and you want them separated by newlines instead you can use `tr` for this: `tr ' ' '\n' < filename – JayJay Jun 08 '17 at 15:25

2 Answers2

1

Use the tr command to replace spaces with newlines.

tr ' ' '\n' < file.txt > newfile.txt
Barmar
  • 9,648
  • 1
  • 19
  • 28
0

If the delimeter is just a space the following command should work:

sed 's/[[:space:]]/\n/g' infilename > outfilename

otherwise use [[:blank:]] to also includ tabs, form feeds, newlines and carriage returens

If there are more spaces/blanks between the words, just use an asterix behind the [[:space:]] :

sed 's/[[:space:]]*/\n/g' infilename > outfilename
Hartmut
  • 199
  • 4