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
i want to know entered string ends with .jar naree Shell Programming and Scripting 3 03-08-2008 07:24 AM
while never ends Raom UNIX for Advanced & Expert Users 4 12-05-2005 01:00 AM
file transfer ends jph Shell Programming and Scripting 4 10-12-2005 06:18 PM
I have not c compile environment ,i can download it but it ends with *.gz,so i can't dsun5 High Level Programming 1 10-11-2001 04:36 AM

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 02-20-2008
hohenheim hohenheim is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 1
[AWK] process field which ends with .dat

This is my first day with awk scripting..Please pardon my ignorance, if any..

I am trying to remove all files ending with .dat

ls -1R xyz/ | awk '$1==*.dat{print "rm " $1}' | bash

ls -1R --> will list files/directories one per line, even the sub directories

I try to match first field of line == *.dat , if true.. remove that file,i know I have not taken care of subdirectory... But that is what I am trying..Any idea how to do it..
  #2 (permalink)  
Old 02-20-2008
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370
Maybe awk isn't the best method... Try this:


Code:
find xyz -type f -name "*.dat" -exec rm {}\;

For the first execution, omit the "-exec ..." part and check the output before removing anything!
  #3 (permalink)  
Old 02-21-2008
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,092
find


Code:
find . -name "*.dat" | xargs rm

  #4 (permalink)  
Old 02-21-2008
manikantants manikantants is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 131
ls -1R *.dat | xargs rm
Closed Thread

Bookmarks

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 07:21 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