The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to read record by record from a file in unix raoscb UNIX for Dummies Questions & Answers 1 05-16-2008 07:30 AM
Script to search a bad record in a file then put the record in the bad file shilendrajadon Shell Programming and Scripting 2 12-28-2007 10:02 AM
Script to search a bad record in a file then put the record in the bad file shilendrajadon UNIX for Advanced & Expert Users 1 12-28-2007 10:00 AM
splitting a record and adding a record to a file rsolap Shell Programming and Scripting 1 08-13-2007 02:58 PM
Regarding deletion of old files Chidvilas Shell Programming and Scripting 3 12-27-2005 10:05 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-14-2007
murtaza murtaza is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 31
Help: deletion of record (without sed, awk, perl)

I have created a address book file. Insertion of Record (using >> symbol)and searching of record (using grep command) into the address book is also working correctly. Now I want to delete a record into a file. Any body can help me in this case without using sed and awk18 18.
Thanks and best regards,

Last edited by murtaza; 03-14-2007 at 08:24 AM.. Reason: Wrong statement
  #2 (permalink)  
Old 03-14-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398

Code:
sed "/pattern/d" file > tmp
mv tmp file


Code:
awk ' $0 !~ /pattern/ { print > "file" } < file


Code:
perl -i -ne ' print if( $_ !~ /pattern/ ) ' file

  #3 (permalink)  
Old 03-14-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
joining this to the list,


Code:
sed -n '/pattern/!p' filename

  #4 (permalink)  
Old 03-14-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926
Quote:
awk ' $0 !~ /pattern/ { print > "file" } < file
That will only work for files with size lesser than the amount
of bytes your awk utility reads from files at a time.
  #5 (permalink)  
Old 03-14-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
Quote:
Originally Posted by radoulov
That will only work for files with size lesser than the amount
of bytes your awk utility reads from files at a time.

Yet to verify that!

and this!


Code:
awk '{ if( !match($0, "pattern") ) { print } }' file

  #6 (permalink)  
Old 03-14-2007
murtaza murtaza is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 31
Sorry for the statement, i had to write without sed and awk. Please tell me the solution without sed and awk
  #7 (permalink)  
Old 03-14-2007
murtaza murtaza is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 31
sorry for wrong statement and pls correct it now

Sorry for the statement, i had to write without sed and awk. Please tell me the solution without sed and awk
Closed Thread

Bookmarks

« grep | format file »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:55 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0