CentOS Icon CentOS Logo
CentOS Text
   
  
www.centos.org Forum Index
   CentOS 5 - General Support
  Need a command to find and remove specific letters from a file

 

 Bottom   Previous Topic   Next Topic
  •  Rate Thread
      Rate this Thread
      Excellent
      Good
      Average
      Bad
      Terrible
Poster Thread
  •  ruriimasu
      ruriimasu
Need a command to find and remove specific letters from a file
#1
Newbie
Joined: 2009/10/29
From
Posts: 7
Hi all,

I have a file with tens of thousands of lines. I need to remove specific letters eg eggs, from every line that has the letters in it. Is there a command which can help me do that easily?

JJ
Posted on: 2009/11/4 3:39
Create PDF from Post Print
Top
  •  ruriimasu
      ruriimasu
Re: Need a command to find and remove specific letters from a file
#2
Newbie
Joined: 2009/10/29
From
Posts: 7
hi.. i found the answer using sed.
Posted on: 2009/11/4 6:25
Create PDF from Post Print
Top
  •  scottro
      scottro
Re: Need a command to find and remove specific letters from a file
#3
Professional Board Member
Joined: 2007/9/3
From NYC
Posts: 666
It's always good to post the command you used. It can help others in the future.
Posted on: 2009/11/4 17:17
Create PDF from Post Print
Top
  •  KB1JWQ
      KB1JWQ
Re: Need a command to find and remove specific letters from a file
#4
Newbie
Joined: 2009/11/4
From
Posts: 1
For those who get stuck and find this using google or whatnot, sed s/egg// will work. The -i flag will do it in place, but that's easily found using the sed man page.
Posted on: 2009/11/4 20:02
Create PDF from Post Print
Top
  •  ruriimasu
      ruriimasu
Re: Need a command to find and remove specific letters from a file
#5
Newbie
Joined: 2009/10/29
From
Posts: 7
oops.. sorry. the command which i found was:

sed 's/the_words_that_you_want_remove_goes_here//g' filename > newfilename

eg to remove "eggs" in my case from file1 and pipe to new file file2:

sed 's/eggs//g' file1 > file2
Posted on: 2009/11/5 9:49
Create PDF from Post Print
Top
 Top   Previous Topic   Next Topic

 


 You cannot start a new topic.
 You can view topic.
 You cannot reply to posts.
 You cannot edit your posts.
 You cannot delete your posts.
 You cannot add new polls.
 You cannot vote in polls.
 You cannot attach files to posts.
 You cannot post without approval.




"Linux" is a registered trademark of Linus Torvalds. | All other trademarks are property of their respective owners. | All other content is Copyright @ 2004-2009 by the CentOS Project or "each individual contributor (forums, comments, etc.) unless otherwise assigned".| Theme based on a theme by 7dana.com