Issue with negative sign after executing the tr command in UNIX

后端 未结 1 670
南旧
南旧 2020-12-12 06:55

My requirement is to convert pipe separated file into normal excel. So I used the below tr command in UNIX to perform this operation. tr \'|\' \',\' < filename.csv > file

相关标签:
1条回答
  • 2020-12-12 07:42

    Instead of tr, you can just use awk to over-write the Output-Field-Separator which in your case is |

    awk '{$1=$1}1' FS="|" OFS=" " filename.csv > filename_Final.csv
    

    The above command over-writes the OFS to a single white-space, hence your input file

    1|abc|-123
    2|def|456
    3|ijk|789
    

    gets converted to

    1 abc -123
    2 def 456
    3 ijk 789
    

    thereby without disturbing the column entries present.

    0 讨论(0)
提交回复
热议问题