Adding a Comma to the end of every nth line in Vi (or sed).
So I have a fairly long list of data that I am trying to put into a math program (maple) but before I can do that I need to edit the format of the data such that at the end of every 25th line I add a comma.
I would prefer a solution that uses vi, but if that's impossible sed would be fine also (or awk). Thanks. |
Here is one with sed
Code:
sed '0~25 s/$/;/' /tmp/lines |
That starts on the 25th line and adds a ";"
If you want line numbers 1, 26, 51, etc. then do sed '1~25s/$/,/' |
I try the sed suggestion and it gives back:
sed: 1: "0~25 s/$/;/": invalid command code ~ Any suggestions? Thanks again for the help |
Hello Euler2 and wellcome to LQ,
here a vim-solution: go to the end of the first line where you want to add a ",". Then Code:
qa25jA,q Code:
@a Code:
50@a Markus |
Quote:
|
Hi,
Welcome to LQ! Now that we are all aware of your 'needs'. What are your 'deeds'? It would be nice if you would share what you've attempted. |
All times are GMT -5. The time now is 02:29 AM. |