I have a file like below -
vipin kumar ........................ kumar ......bangalore
something something .......
;
vipin kumar ........................ kumar ......bangalore
something something .......(testing
)
;
vipin kumar ......................... kumar .....bangalore
something something ;
I want the output like below ( name and number can be different in the file but the only thing that is common - line is ending when we have ";")
vipin kumar ........................ kumar ......bangalore something something .......;
vipin kumar ........................ kumar ......bangalore something something .......(testing);
vipin kumar ......................... kumar .....bangaloresomething something ;
I want to set the RS to ";" .
I tried below commands -
awk '{ORS=(NR%2==0?RS:FS)}1' file.txt
but it is not giving the correct output because
NR%2 or NR%3
won't work as i am not sure after how many lines i will get ;
then i tried to set the RS to ; using below
awk '{for(i=1;i<=NF;i++) (ORS=(if($i ~ /;/?RS:FS);break}1' file.txt
But this command is not working.
Input
$ cat f
vipin kumar ........................ kumar ......bangalore
something something .......
;
vipin kumar ........................ kumar ......bangalore
something something .......(testing
)
;
vipin kumar ......................... kumar .....bangalore
something something ;
Output
$ awk 'ORS=/;/?RS:FS' f
vipin kumar ........................ kumar ......bangalore something something ....... ;
vipin kumar ........................ kumar ......bangalore something something .......(testing ) ;
vipin kumar ......................... kumar .....bangalore something something ;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With