LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-26-2005, 10:00 AM   #1
daYz
Member
 
Registered: Nov 2003
Distribution: Ubuntu
Posts: 164

Rep: Reputation: 30
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.
 
Old 11-26-2005, 10:09 AM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
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..
 
Old 11-26-2005, 11:44 AM   #3
daYz
Member
 
Registered: Nov 2003
Distribution: Ubuntu
Posts: 164

Original Poster
Rep: Reputation: 30
Great help!

I have got it working.

Thanks a lot

Regards,

Ben
 
Old 11-26-2005, 06:09 PM   #4
zahadumy
Member
 
Registered: May 2005
Location: Cluj, Romania
Distribution: Fedora Core 6
Posts: 226

Rep: Reputation: 31
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to remove lines from a file doza Linux - General 2 04-27-2005 11:59 AM
how to remove all commented lines win32sux Linux - General 11 05-08-2004 03:27 AM
remove identical lines in a file benjithegreat98 Linux - General 4 04-24-2004 06:12 AM
How do i remove blank lines from a file? kakho Programming 1 04-15-2004 03:57 AM
[bash] remove lines from a file Drimo Programming 3 03-20-2004 11:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration