need help in remove group of files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need help in remove group of files
# 1  
Old 09-16-2008
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  
Old 09-16-2008
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.ThanksSmilie
# 3  
Old 09-16-2008
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  
Old 09-16-2008
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  
Old 09-16-2008
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  
Old 09-16-2008
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  
Old 09-16-2008
Try gzcat instead.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Replace Stub Values In One Group Of Files With Actual Values From Another Group Of Files

I have two directories of files (new-config-files and old-config-files): new-config-files/this-db/config.inc.php new-config-files/that-db/config.inc.php new-config-files/old-db/config.inc.php new-config-files/new-db/config.inc.php new-config-files/random-database/config.inc.php etc. ... (4 Replies)
Discussion started by: spacegoose
4 Replies

2. UNIX for Dummies Questions & Answers

Remove a secondary group from user (Linux)

Oracle Linux 6.6 grid user's secondary groups are asmadmin,asmdba,asmoper and dba # id -a grid uid=638(grid) gid=2000(oinstall) groups=2000(oinstall),2100(asmadmin),2200(dba),2300(asmdba),2301(asmoper) I want to remove dba as the secondary group for grid and keep the remaining ones. ie. I... (5 Replies)
Discussion started by: John K
5 Replies

3. Shell Programming and Scripting

Remove duplicate based on Group

Hi, How can I remove duplicates from a file based on group on other column? for example: Test1|Test2|Test3|Test4|Test5 Test1|Test6|Test7|Test8|Test5 Test1|Test9|Test10|Test11|Test12 Test1|Test13|Test14|Test15|Test16 Test17|Test18|Test19|Test20|Test21 Test17|Test22|Test23|Test24|Test5 ... (2 Replies)
Discussion started by: yale_work
2 Replies

4. Shell Programming and Scripting

sed or tr to remove specific group of special characters

Hi, I have a input of the form: ..., word1, word2, word3... I want out put of the form word1, word2, word3 I tried echo '..., word1, word2, word3...' | tr -d '...,' but that takes out the commas in the middle too so I get word1 word2 word3 but I want the commas in the middle. ... (3 Replies)
Discussion started by: forumbaba
3 Replies

5. UNIX for Dummies Questions & Answers

Need to remove Group write permission .

How would i write a command that can find all the objects under the etc directory that have group write permission enabled and have not been accessed in the last X days. This is what i got from internet souce but i m not able to modify it according to my distribution. find /etc -perm... (1 Reply)
Discussion started by: pinga123
1 Replies

6. UNIX for Dummies Questions & Answers

How to remove group write bit?

I know this may sound little incomplete but this is what i read on some linux hardening guide.I dont have any clue on how to remove group's write bit. I m posting the exact sentence of the hardening guide. What all system files to be taken care of? ---------- Post updated 10-04-10 at... (3 Replies)
Discussion started by: pinga123
3 Replies

7. HP-UX

Unmount and remove all Logical vol.Volume group and physical disk

Hi, Someone please help me with how i can unmount and remove all the files systems from a cluster. This is being shared by two servers that are active_standby. (3 Replies)
Discussion started by: joeli
3 Replies

8. Shell Programming and Scripting

Find all files with group read OR group write OR user write permission

I need to find all the files that have group Read or Write permission or files that have user write permission. This is what I have so far: find . -exec ls -l {} \; | awk '/-...rw..w./ {print $1 " " $3 " " $4 " " $9}' It shows me all files where group read = true, group write = true... (5 Replies)
Discussion started by: shunter63
5 Replies

9. AIX

Remove volume group it's lvs and filesystems after vg's pv was deleted ?

Hi, Physical volume of vg was removed permanently by acident. What I need right now is to remove all vg's objects(vg itself, vg's lvs, vg's filesystems) to prepare to add new pv and create new volume group and it's objects. This is from reducevg manual: "Sometimes a disk is removed from the... (2 Replies)
Discussion started by: vilius
2 Replies

10. Solaris

How to remove user from a group using command line

Hi, Wanted to remove a user from a group , but no GUI , must use command line (2 Replies)
Discussion started by: civic2005
2 Replies
Login or Register to Ask a Question