I am completely new to bash and I have a file that contains some string records, let's say
1,2,3,4,5
6,7,8,9,10
11,12,13,14,15
and I need to make another file that looks like this:
2 4 5 3 1
7 9 10 8 6
...
but I got this:
2 4 5
3 1
7 9 10
8 6
The problem is probably caused by the fact that there is no delimiter at the end of the line and it takes enter when printing, but I don't know how to solve this.
#!/bin/bash
FILE=file.txt
a=$(cut -d',' -f2 $FILE)
b=$(cut -d',' -f4 $FILE)
c=$(cut -d',' -f5 $FILE)
d=$(cut -d',' -f3 $FILE)
e=$(cut -d',' -f1 $FILE)
paste <(echo "$a") <(echo "$b") <(echo "$c") <(echo "$d") <(echo "$e") --delimiters ' '> new.txt