![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to delete content in a file (delete content only) | kittusri9 | Shell Programming and Scripting | 5 | 05-15-2008 10:12 AM |
| delete in c++ | nandlal | High Level Programming | 4 | 02-02-2008 09:48 AM |
| C++ = new and delete | arun.viswanath | High Level Programming | 3 | 09-13-2005 07:16 PM |
| delete | lesstjm | UNIX for Dummies Questions & Answers | 3 | 11-08-2001 12:24 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need Help to delete Smartly...!!!
There is a Directory...Master(say)
under this there are further sub-directories... (say) A B C D E,etc These sub-directories contains files in the format somestring_20070502{yyyymmdd}format.dat. I want to delete files of month's SMARTLY w/o getting into each sub-directory. Note Each each day i receive files in the sub-folders, eveyr month i need to delete the files manually. Can you help me in writing the script(or smart one-liners will also do) to ease the tasks...!!! Cheers Kunal |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Which ones exactly do you want to delete? Only those for a specific date? Would this not do what you require?
Code:
rm /Master/?/*_20070502.dat |
|
#3
|
|||
|
|||
|
find . -name \*.dat -atime +30 -print | xargs rm
|
|
#4
|
|||
|
|||
|
rm /Master/?/*_20070502.dat is not working...
under Master I want to delete all files *.20070502.dat from all sub-folders. |
|
#5
|
|||
|
|||
|
Change the _ to a . then??
I'm presuming /Master is off the root directory. If not, then obviously you will need to supply the correct path, or cd into it first and just use rm ?/*.20070502.dat. I'm also presuming that the directories under Master have just single-letter names. If not, replace ? with *. |
|
#6
|
|||
|
|||
|
/home/users/Master - under this there are 5 sub-directories which contains
string_yyyymmdd.dat files I want to remove the yyymmdd files from all sub-directores.. above is still not working.... |
|
#7
|
|||
|
|||
|
You are contradicting yourself. On your previous post you said *.20070502.dat, but now you are saying *_20050702.dat. Are you sure which one is correct?
Presuming it is _, This should work: Code:
rm /home/users/Master/*/*_20070502.dat Code:
find /home/users/Master/* -name '*_20070502.dat' | xargs rm |
|||
| Google The UNIX and Linux Forums |