1

I have a file which contains one line like this

test1.CSV test2.CSV test3.CSV test4.CSV...

I want to put a line break after each .CSV file name like so

test1.CSV
test2.CSV
test3.CSV
test4.CSV

Thanks

2 Answers 2

1

The tr utility could be used to replace each space by a newline like so:

tr ' ' '\n' <infile >outfile

If there are multiple spaces between the filenames on the line, you may compress the generated newlines into single ones using tr -s.

This obviously assumes that none of the filenames contain embedded space characters.

You may also achieve the same affect with sed:

sed 'y/ /\n/' infile >outfile
0

Use sed:

$ sed 's/ /\n/g' file

where file is the name of the file to be edited.

1
  • 1
    That requires GNU sed. Commented Apr 23, 2019 at 11:40

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.