Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
google site



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

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Search this Thread
  #1  
Old 03-12-2010
jaysunn's Avatar
Registered User
 

Join Date: May 2009
Posts: 54
Thanks: 13
Thanked 3 Times in 2 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: 5,786
Thanks: 2
Thanked 94 Times in 89 Posts

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

  #3  
Old 03-12-2010
dennis.jacob's Avatar
dj - the student
 

Join Date: Feb 2007
Location: Bangalore/Cochin
Posts: 860
Thanks: 0
Thanked 5 Times in 4 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: 5,786
Thanks: 2
Thanked 94 Times in 89 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
  #5  
Old 03-12-2010
jaysunn's Avatar
Registered User
 

Join Date: May 2009
Posts: 54
Thanks: 13
Thanked 3 Times in 2 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
Reply

Thread Tools Search this Thread
Search this Thread:

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


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 09:20 PM.