Search code examples
bashshellcut

Cut -f parameter not working correctly


I use next command

out=cat /path/myFile | cut -f2,3 -d ',' | sed -r -e 's/,/ /g

myFile looks like:

a1a1a1a1,b1b1b1b1,c1c1c1c1,d1d1d1d1d1
a2a2a2a2,b2b2b2b2,c2c2c2c2,d2d2d2d2d2
a3a3a3a3,b3b3b3b3,c3c3c3c3,d3d3d3d3d3

and after i would got :

b1b1b1b1 c1c1c1c1
b2b2b2b2 c2c2c2c2

but result is write at one line:

b1b1b1b1 c1c1c1c1 b2b2b2b2 c2c2c2c2 ...

Any suggestion?


Solution

  • Probably you are saying echo $out without quotes instead if the correct

    echo "$out"