I have the following file (example.txt):
blue(4) red(8) green(5) yellow(19) brown(60) black(5)
how can i achieve the following result in unix?
The following built-in sed script will replace the space with a new line and should solve your problem.
sed -i 's/ /\n/g' example.txt > example_out.txt
If you need to insert a new line after closing the brackets, try
sed 's/) \?/)\n/g' example.txt
xargs -n 1 < example.txt
example.txt xargs -n 1, xargs .
example.txt
-n 1
, , -n 1 -n 2
-n 2
-n max-args .
-n
max-args
sed, :
sed 's/ /\n/g' example.txt