DaemonForums  

Go Back   DaemonForums > Miscellaneous > Programming

Programming C, bash, Python, Perl, PHP, Java, you name it.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 12th November 2008
bigb89 bigb89 is offline
Fdisk Soldier
 
Join Date: May 2008
Posts: 69
Default Deleting lines with certain letters/keywords.

Hi Guys,

I've tried google, but I could not find any answer. Here's what I need to do:

If I have a file that contains the letter a on certain lines, for example:

53a1
54b2
54o7
56a2

How could I delete the lines the have the letter a on it so the new file would loo like this:

54b2
54o7

P.S. I don't really mind the programming language to use to perform the above (perl, sed, tr, etc).

Regards,
--Bigb89
Reply With Quote
  #2   (View Single Post)  
Old 12th November 2008
DutchDaemon's Avatar
DutchDaemon DutchDaemon is offline
Real Name: Ben
Spam Refugee
 
Join Date: Jul 2008
Location: Rotterdam, The Netherlands
Posts: 336
Default

grep -v a file > newfile
(mv newfile file)
Reply With Quote
  #3   (View Single Post)  
Old 12th November 2008
graudeejs's Avatar
graudeejs graudeejs is offline
Real Name: Aldis Berjoza
ISO Quartermaster
 
Join Date: Jul 2008
Location: Riga, Latvia
Posts: 589
Default

Code:
cat testfile | grep -v a > testfile2
EDIT: you were faster... thanks for your line (better than mine)
I learned something

Last edited by graudeejs; 12th November 2008 at 04:54 PM.
Reply With Quote
  #4   (View Single Post)  
Old 12th November 2008
bsddaemon bsddaemon is offline
Slack Daemon
 
Join Date: Oct 2008
Posts: 35
Default

Code:
cat foo && echo "===> Output:" && sed '/a/d' foo
53a1
54b2
54o7
56a2
===> Output:
54b2
54o7
__________________
...then the God created man...

Last edited by bsddaemon; 12th November 2008 at 04:58 PM.
Reply With Quote
  #5   (View Single Post)  
Old 12th November 2008
bigb89 bigb89 is offline
Fdisk Soldier
 
Join Date: May 2008
Posts: 69
Default

Thanks everyone!

I'll be trying that out.
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Putting Lines to Together. bigb89 Programming 4 24th September 2008 03:59 AM
Adding multiple lines into file c0mrade Programming 4 7th June 2008 11:03 PM


All times are GMT. The time now is 04:35 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick