Re: script help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



adrian kok wrote:
Hi

I have script to remove files but it can't work in
directory


ls *log | sort -r | sed -e 1,1d | xargs rm -f

those folders are:

Nov28-log
Nov29-log
Nov30-log

What is it you are trying to do here? Are you trying to remove files in the directory leaving the directory name, or remove the directory, or ??? What is the sort trying to do, given that month names don't occur in alphabetical order...

If you are trying to remove all but the two most recent directories (I'm guessing here):
 ls -dt *-log | tail -n +3 | xargs rm -rf

That won't work if filenames contain blanks, something I fight daily.

--
Bill Davidsen <davidsen@xxxxxxx>
  "We have more to fear from the bungling of the incompetent than from
the machinations of the wicked."  - from Slashdot

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux