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.
JavaScript
x
2
1
randomFileName1, randomFileName2, randomFileName3, etc.
2
I want to take each value in the list and put it into its own row in a new CSV file.
JavaScript
1
4
1
randomFileName1
2
randomFileName2
3
randomFileName3
4
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
:
JavaScript
1
2
1
sed 's|, |n|g' file
2
Or, for a portable alternative,
JavaScript
1
3
1
sed 's|, |
2
|g' file
3