Delete specific newlines on a file.
Hi Friends,
I have a procedure for delete some specific newline on a file. For example with the file ex01: Code:
Chiarot:teddy$cat ex01 Code:
sed Code:
Chiarot:teddy$cat pr.sh Some ideas to reduce this code?. |
You could store the temporary parts in variables, something like this:
Code:
#!/bin/bash or even better.. Code:
#!/bin/bash |
That's a good idea, thanks coralfang.
It works very well, but there is no way to use only sed for replace nilB, nilC and nilD for nothing and paste this lines only with sed into the file?. It could work even better than now. |
Finally find a even better solution:
Code:
sed -e '/^nil/{:a;N;$!ba;s/\n//g}' -e 's/nil[B|C|D]//g' /tmp/ex01 > /tmp/ex01Final |
This is the final expression:
Code:
sed -i '/^nil/{:a;N;$!ba;s/\n//g;s/nil[B|C|D]//g}' /tmp/ex01 Code:
sed -e '/^nil/{:a;N;$!ba;s/\n//g;s/nil[B|C|D]//g}' /tmp/ex01 > /tmp/ex01Final |
With this InFile ...
Code:
Chiarot:teddy$cat ex01 Code:
awk -F, '{if (substr($0,1,3)!="nil") print Code:
Chiarot:teddy$cat ex01 |
All times are GMT -5. The time now is 08:19 PM. |