Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



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

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-12-2010
jaysunn's Avatar
Registered User
 

Join Date: May 2009
Location: NYC - USA
Posts: 92
Thanks: 21
Thanked 5 Times in 4 Posts
awk search & delete located criteria

Guys,
I manages to get awk to search and print the files that I want to delete. However I am stuck on the delete portion.

Here is the command that I am using to fins these files.

Code:
find /usr/local/apache/conf/vhosts/ -type f | awk '/e$/'

The output is perfect. The files look like so:


Code:
/usr/local/apache/conf/vhosts/kydzradiolv.com\e
/usr/local/apache/conf/vhosts/stylefm.kyee
/usr/local/apache/conf/vhosts/foxcountry.useee
/usr/local/apache/conf/vhosts/old2-rooster101.kyee
/usr/local/apache/conf/vhosts/foxcountry.usee
/usr/local/apache/conf/vhosts/rooster101.kyee
/usr/local/apache/conf/vhosts/itm-eee
/usr/local/apache/conf/vhosts/king.orgeee
/usr/local/apache/conf/vhosts/old2-z99.kyee
/usr/local/apache/conf/vhosts/cjcy.loungeradio.caeee
/usr/local/apache/conf/vhosts/charityawardsprogram.useee

I want all of the findings deleted. I have tried the following with no luck:


Code:
find /usr/local/apache/conf/vhosts/ -type f | awk '/e$/d'

Any ideas?

Jaysunn
Sponsored Links
    #2  
Old 03-12-2010
Moderator
 

Join Date: Feb 2007
Location: The Netherlands
Posts: 7,289
Thanks: 55
Thanked 427 Times in 408 Posts

Code:
find /usr/local/apache/conf/vhosts/ -type f | awk '/e$/{system("rm " $0)}'

Sponsored Links
    #3  
Old 03-12-2010
dennis.jacob's Avatar
Registered User
 

Join Date: Feb 2007
Location: Singapore/Cochin
Posts: 871
Thanks: 0
Thanked 10 Times in 9 Posts
Why not



Code:
find /usr/local/apache/conf/vhosts/ -name "*e" -type f -exec rm {} \;

    #4  
Old 03-12-2010
Moderator
 

Join Date: Feb 2007
Location: The Netherlands
Posts: 7,289
Thanks: 55
Thanked 427 Times in 408 Posts
Quote:
Originally Posted by dennis.jacob View Post
Why not



Code:
find /usr/local/apache/conf/vhosts/ -name "*e" -type f -exec rm {} \;

Of course!, professional blindness
Sponsored Links
    #5  
Old 03-12-2010
jaysunn's Avatar
Registered User
 

Join Date: May 2009
Location: NYC - USA
Posts: 92
Thanks: 21
Thanked 5 Times in 4 Posts
[solved]

Hmm @dennis.jacob,

I thought that I needed the $ to anchor all the end e's. But your solution is correct.

Thanks.

Jaysunn
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Search and delete ak835 Shell Programming and Scripting 1 01-25-2010 08:59 AM
Delete new lines based on search criteria jayarkay Shell Programming and Scripting 3 01-19-2010 01:36 AM
Append specific lines to a previous line based on sequential search criteria jesse Shell Programming and Scripting 3 08-21-2009 02:01 AM
{How} Script to search a log file for a given criteria indiakingz Shell Programming and Scripting 9 08-05-2008 03:42 PM
Select records based on search criteria on first column shashi_kiran_v UNIX for Dummies Questions & Answers 2 12-02-2005 12:49 PM



All times are GMT -4. The time now is 03:40 AM.