![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| shell script to delete directories... | Stephan | Shell Programming and Scripting | 5 | 05-16-2008 09:11 AM |
| How to delete files in UNIX using shell script | theguy16 | Shell Programming and Scripting | 7 | 04-09-2008 05:40 AM |
| script to delete files | vats | Shell Programming and Scripting | 12 | 09-01-2007 06:27 AM |
| Need Help: Delete a file by Shell Script | r3edi | Shell Programming and Scripting | 5 | 07-11-2005 08:13 AM |
| how to delete empty files in a shell script | rpnuge | UNIX for Advanced & Expert Users | 1 | 07-11-2002 05:56 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
i want to delete all the files in my directory except the latest one. i need to do this from shell script.
say i have a.txt - latest file b.txt, c.txt.. it should delete all the files except a.txt? |
|
||||
|
Hi satyajit007,
Put the following 2 lines in your script file and make your script file executable with "chmod +x script_file" and then run your script file. new_file=`ls -ltr|grep -v drw|tail -1` find . -type f ! -newer $new_file -maxdepth 1 -exec rm {} \; |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|