I have a Python script that outputs a text file with thousands of random filenames in a comma separated list, all on a single row.
randomFileName1, randomFileName2, randomFileName3, etc.
I want to take each value in the list and put it into its own row in a new CSV file.
randomFileName1 randomFileName2 randomFileName3
I’ve tried some variations of awk
with no success. What’s the best way to move these values into their own rows?
Advertisement
Answer
With GNU sed
:
sed 's|, |n|g' file
Or, for a portable alternative,
sed 's|, | |g' file