LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-04-2010, 05:52 PM   #16
vbekker
Member
 
Registered: Aug 2010
Location: Brooklyn, NY
Distribution: CentOS
Posts: 38

Original Poster
Rep: Reputation: 0

can that be fixed with a Q?
Code:
ls -1tQ
 
Old 12-04-2010, 05:55 PM   #17
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi,
Quote:
Originally Posted by vbekker View Post
Code:
rm -rf $(ls -1t | tail -n +7)
As already stated by GrapefruiTgirl, this won't work with "special" files.

Try adding ls's -Q option (puts quotes around the filenames):
Code:
rm -rf $(ls -1Qt | tail -n +7)
Untested........

Hope this helps.

And it seems I was a bit slow in replying ;-)

Last edited by druuna; 12-04-2010 at 05:55 PM. Reason: ... Way to slow.....
 
Old 12-04-2010, 05:56 PM   #18
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
vbekker - I tried it, now you try it. Let us know how it works.
 
Old 12-04-2010, 10:13 PM   #19
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,251

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
Well I tried it too ... arooga arooga ... danger will robinson
 
Old 12-13-2010, 02:25 PM   #20
chickenjoy
Member
 
Registered: Apr 2007
Distribution: centos,rhel, solaris
Posts: 200

Rep: Reputation: 30
Code:
rm -rf $(ls -1t | tail -n +7)
hmm isn't supposed to be +8 to retain the items 1 to 7 and only 8 and upwards will be piped to the rm command?

looks like the 'Q' embeds quotation marks:

"file 1"
"file 2"

so what it does is:

rm -rf $"file 1" = but it doesn't delete anything....
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete files in a directory - RM MDeFreitas Linux - Newbie 3 06-25-2010 08:00 AM
sort files inside a directory and sub-directories by latest created walidaly Linux - Software 8 07-25-2009 03:45 PM
Delete Files in directory villumanati Linux - General 7 12-30-2008 02:18 PM
How to delete once whole files in a remote directory? backpacker Linux - Networking 1 03-10-2006 06:04 AM
How can I delete a directory and its files? OrganicX Linux - General 6 09-01-2002 05:25 AM


All times are GMT -5. The time now is 07:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration