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 remove user from a group using command line civic2005 SUN Solaris 2 09-18-2008 03:05 PM
uncompress a group of files ali560045 Shell Programming and Scripting 8 09-05-2008 03:02 AM
How to listout the files based on group by the date...? psiva_arul UNIX for Dummies Questions & Answers 3 04-21-2008 10:03 AM
listing sequential files as one group... kentm UNIX for Advanced & Expert Users 1 01-24-2007 06:11 PM
group by in files :-) hellsd UNIX for Dummies Questions & Answers 10 06-22-2005 12:47 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 09-16-2008
ali560045's Avatar
ali560045 ali560045 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 328
need help in remove group of files

i have some 350 files in a dir: i want to remove them in one shot,

ls -ltr | grep 'Sep 15' | head -350

the above command gives me those 350 files i need to remove them,how to implement remove logic here in this command?


i can get those 350 files using the above command only and therefore i want to implement the remove command there only.

plz help me in this
  #2 (permalink)  
Old 09-16-2008
OSD OSD is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 24
Hello,

Try this

find . -mtime -1 -exec rm -rf {} \;

-mtime -1 gives you the files for sep 16th i.e today..
find . -mtime -1 -print ---try this first.see if you get 350 files.if yes,
execute the above command on the prompt.Thanks
  #3 (permalink)  
Old 09-16-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
Alternatively:


Code:
ls -ltr | grep 'Sep 15' | head -350 | awk '{print $NF}' | xargs rm

Although awk can do the grep and head work too:


Code:
ls -ltr | awk '/Sep 15/ && NR<=350 {print $NF}' | xargs rm

  #4 (permalink)  
Old 09-16-2008
ali560045's Avatar
ali560045 ali560045 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 328
Thanks i got it . Thanks to all for their help.

One more thing i wanted to ask , i have a file which is tar and then gz

CurrentCollectorMeterReadBackup20080915.tar.gz

How to search for a file log1.txt inside the above file without uncompressing it. I mean to say how to do this

CurrentCollectorMeterReadBackup20080915.tar.gz | grep 'log1.txt '
  #5 (permalink)  
Old 09-16-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
You need to uncompress the data in order to examine it, although of course, you don't need to commit the uncompressed data anywhere.


Code:
zcat file.tar.gz | tar tf - log1.txt

... assuming your tar accepts a file name to extract from the tar archive.
  #6 (permalink)  
Old 09-16-2008
ali560045's Avatar
ali560045 ali560045 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 328
i used the below command:It's giving error

zcat CurrentCollectorMeterReadBackup20080915.tar.gz | tar tf - CurrentCollectorMeterReadBackup_20081915051914684

Error:

CurrentCollectorMeterReadBackup20080915.tar.gz.Z: No such file or directory
tar: tape read error: unexpected EOF
  #7 (permalink)  
Old 09-16-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Try gzcat instead.
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 05:58 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