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 the file by removing all the parenthesis and a new line for each couple so that it look like this:
-9.1744438E-02,7.6282293E-02
-9.1744438E-02,7.6282293E-02
...
A simple way to do that?
Any help is appreciated,
Fred
Due to formatting issues, it is not entirely clear from your question whether you also need to insert newlines.
This might work for you:
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
and again,
And the results were:
05.44 sec : Using tr
05.57 sec : Using sed
This would work -
Test:
I would use
tr
for this job:With the
-d
switch it just deletes any characters in the given set.To add new lines you could pipe it through two
tr
s:As was said, almost:
or in awk: