View previous topic :: View next topic |
Author |
Message |
dcstimm Guru
Joined: 19 Jun 2002 Posts: 321
|
Posted: Mon Aug 12, 2002 11:50 pm Post subject: cleaning out the home directory |
|
|
Hey guys,
I have been looking for a easy way of cleaning out my home directory, and i found it would be easy to
ls > blah
then go though blah with vi and dd to all the files I want to keep, and have a basic list off all the packages I want to delete.
How I have a list of packages that I wish to delete, is there a simple command or script I could make that could read the blah file and delete anything that is in it?
Just a question..
it would be easier than doing rm file.tar.gz rm -rf direcotry
or using a GUI file manager.
thanks! |
|
Back to top |
|
|
rac Bodhisattva
Joined: 30 May 2002 Posts: 6553 Location: Japanifornia
|
Posted: Mon Aug 12, 2002 11:52 pm Post subject: |
|
|
How about: Code: | $ cat blah | xargs rm |
_________________ For every higher wall, there is a taller ladder |
|
Back to top |
|
|
dcstimm Guru
Joined: 19 Jun 2002 Posts: 321
|
Posted: Tue Aug 13, 2002 12:26 am Post subject: |
|
|
okay I tried it but I get this:
cat blah | xargs rm -rf
xargs: unmatched single quote
i need the -rf to delete the directories listed in the blah file |
|
Back to top |
|
|
rac Bodhisattva
Joined: 30 May 2002 Posts: 6553 Location: Japanifornia
|
Posted: Tue Aug 13, 2002 12:53 am Post subject: |
|
|
Adding -rf shouldn't cause any problems. You may need to escape (by preceding with a \ inside blah) ugly bad characters like ' and space that are no fun to have in Unix filenames in general. _________________ For every higher wall, there is a taller ladder |
|
Back to top |
|
|
Naan Yaar Bodhisattva
Joined: 27 Jun 2002 Posts: 1549
|
Posted: Tue Aug 13, 2002 12:55 am Post subject: |
|
|
Try:
Code: |
cat blah | tr '\n' '\0' | xargs --null rm -r
|
|
|
Back to top |
|
|
puddpunk l33t
Joined: 20 Jul 2002 Posts: 681 Location: New Zealand
|
Posted: Tue Aug 13, 2002 8:06 am Post subject: |
|
|
Go into your /home dir and type:
rm -ir *
it will interactively ask you which files you want to delete. |
|
Back to top |
|
|
masseya Bodhisattva
Joined: 17 Apr 2002 Posts: 2602 Location: Baltimore, MD
|
Posted: Tue Aug 13, 2002 2:13 pm Post subject: |
|
|
puddpunk wrote: | Go into your /home dir and type:
rm -ir *
it will interactively ask you which files you want to delete. |
Wow, just don't forget the 'i'... _________________ if i never try anything, i never learn anything..
if i never take a risk, i stay where i am.. |
|
Back to top |
|
|
arkane l33t
Joined: 30 Apr 2002 Posts: 918 Location: Phoenix, AZ
|
Posted: Tue Aug 13, 2002 5:40 pm Post subject: |
|
|
You know, this is one of those tasks that I'd hvae to say a GUI has a massive advantage over. Not downing the command prompt, but the GUI is excellent for this type of thing.
Gotta love the ability to hold down the ctrl key and select things, then hitting delete and watch them go bye-bye.
Well, sometimes... under KDE you have to empty the trashcan. |
|
Back to top |
|
|
masseya Bodhisattva
Joined: 17 Apr 2002 Posts: 2602 Location: Baltimore, MD
|
Posted: Tue Aug 13, 2002 5:49 pm Post subject: |
|
|
arkane wrote: | Well, sometimes... under KDE you have to empty the trashcan. |
No, that's windows... Oh, wait... nevermind... _________________ if i never try anything, i never learn anything..
if i never take a risk, i stay where i am.. |
|
Back to top |
|
|
arkane l33t
Joined: 30 Apr 2002 Posts: 918 Location: Phoenix, AZ
|
Posted: Tue Aug 13, 2002 5:51 pm Post subject: |
|
|
Tristam29 wrote: | arkane wrote: | Well, sometimes... under KDE you have to empty the trashcan. |
No, that's windows... Oh, wait... nevermind... |
No no no... you see, Microsoft is far more ecologically friendly!
They use a recycle bin.. it's not socially sound to just throw your trash away you know, you have to recycle! |
|
Back to top |
|
|
proxy Apprentice
Joined: 20 Apr 2002 Posts: 260 Location: Chantilly, VA
|
Posted: Tue Aug 13, 2002 6:24 pm Post subject: |
|
|
err, why not just do:
?
to easy? |
|
Back to top |
|
|
Naan Yaar Bodhisattva
Joined: 27 Jun 2002 Posts: 1549
|
Posted: Tue Aug 13, 2002 7:13 pm Post subject: |
|
|
This will not work if there are spaces in filenames in blah.
proxy wrote: | err, why not just do:
?
to easy? |
|
|
Back to top |
|
|
proxy Apprentice
Joined: 20 Apr 2002 Posts: 260 Location: Chantilly, VA
|
Posted: Tue Aug 13, 2002 7:20 pm Post subject: |
|
|
do'h! see i knew it was too easy
proxy |
|
Back to top |
|
|
Naan Yaar Bodhisattva
Joined: 27 Jun 2002 Posts: 1549
|
Posted: Tue Aug 13, 2002 7:32 pm Post subject: |
|
|
This will work with most stuff you throw at it:
cat blah | tr '\n' '\0' | xargs --null rm -r
It replaces newlines with '\0's and then runs xargs with the --null arg (which will make it not treat spaces and quotes as special chars and use '\0' as the separator).
proxy wrote: | do'h! see i knew it was too easy
proxy |
|
|
Back to top |
|
|
|