AWK/SED. How to remove parentheses in simple text file

后端 未结 6 2132
无人共我
无人共我 2021-02-07 11:14

I have a text file looking like this:

(-9.1744438E-02,7.6282293E-02) (-9.1744438E-02,7.6282293E-02)  ... and so on.

I would like to modify th

6条回答
  •  臣服心动
    2021-02-07 11:37

    Guess we all know this, but just to emphasize:

    Usage of bash commands is better in terms of time taken for execution, than using awk or sed to do the same job. For instance, try not to use sed/awk where grep can suffice.

    In this particular case, I created a file 100000 lines long file, each containing characters "(" as well as ")". Then ran

    $  /usr/bin/time -f%E -o log cat file | tr -d "()"
    

    and again,

    $  /usr/bin/time -f%E -ao log sed 's/[()]//g' file
    

    And the results were:

    05.44 sec : Using tr

    05.57 sec : Using sed

提交回复
热议问题