LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to remove the first part of lines? (https://www.linuxquestions.org/questions/linux-software-2/how-to-remove-the-first-part-of-lines-386683/)

daYz 11-26-2005 10:00 AM

How to remove the first part of lines?
 
Hi

I have a file where I want to remove the first part of every line in that file. Does someone know with what command I can do that?
Every line starts with "added:" which is the part I want to remove.

Thanks for your help.

trickykid 11-26-2005 10:09 AM

sed 's/added://' filename > newfile

or you can open up something like vi and do this command in command mode:

1:$ s/added://g

You could also get fancy with awk as well..

man sed
man awk
man vi

for more details..

daYz 11-26-2005 11:44 AM

Great help!

I have got it working.

Thanks a lot

Regards,

Ben

zahadumy 11-26-2005 06:09 PM

Quote:

Originally posted by trickykid
or you can open up something like vi and do this command in command mode:
1:$ s/added://g

I know how sed works so it doesn't have any connection with this thread, but I'm curious how do you do this with vi. Because I've been a couple of times in the situation to have to exit vi, call a sed and after this go back to vi. Is it possible to do this directly from vi? I trid to write "s/.../.../g" in vi command line but it didn't work. How do you do it? I couldn't find anything in the manual page of vi either.


All times are GMT -5. The time now is 03:17 PM.