Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
cleaning out the home directory
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
dcstimm
Guru
Guru


Joined: 19 Jun 2002
Posts: 321

PostPosted: Mon Aug 12, 2002 11:50 pm    Post subject: cleaning out the home directory Reply with quote

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
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Mon Aug 12, 2002 11:52 pm    Post subject: Reply with quote

How about:
Code:
$ cat blah | xargs rm

_________________
For every higher wall, there is a taller ladder
Back to top
View user's profile Send private message
dcstimm
Guru
Guru


Joined: 19 Jun 2002
Posts: 321

PostPosted: Tue Aug 13, 2002 12:26 am    Post subject: Reply with quote

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
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Tue Aug 13, 2002 12:53 am    Post subject: Reply with quote

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
View user's profile Send private message
Naan Yaar
Bodhisattva
Bodhisattva


Joined: 27 Jun 2002
Posts: 1549

PostPosted: Tue Aug 13, 2002 12:55 am    Post subject: Reply with quote

Try:
Code:

cat blah | tr '\n' '\0' | xargs --null rm -r
Back to top
View user's profile Send private message
puddpunk
l33t
l33t


Joined: 20 Jul 2002
Posts: 681
Location: New Zealand

PostPosted: Tue Aug 13, 2002 8:06 am    Post subject: Reply with quote

Go into your /home dir and type:

rm -ir *

it will interactively ask you which files you want to delete.
Back to top
View user's profile Send private message
masseya
Bodhisattva
Bodhisattva


Joined: 17 Apr 2002
Posts: 2602
Location: Baltimore, MD

PostPosted: Tue Aug 13, 2002 2:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
arkane
l33t
l33t


Joined: 30 Apr 2002
Posts: 918
Location: Phoenix, AZ

PostPosted: Tue Aug 13, 2002 5:40 pm    Post subject: Reply with quote

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
View user's profile Send private message
masseya
Bodhisattva
Bodhisattva


Joined: 17 Apr 2002
Posts: 2602
Location: Baltimore, MD

PostPosted: Tue Aug 13, 2002 5:49 pm    Post subject: Reply with quote

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
View user's profile Send private message
arkane
l33t
l33t


Joined: 30 Apr 2002
Posts: 918
Location: Phoenix, AZ

PostPosted: Tue Aug 13, 2002 5:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
proxy
Apprentice
Apprentice


Joined: 20 Apr 2002
Posts: 260
Location: Chantilly, VA

PostPosted: Tue Aug 13, 2002 6:24 pm    Post subject: Reply with quote

err, why not just do:

Code:
rm -rf `cat blah`


?

to easy?
Back to top
View user's profile Send private message
Naan Yaar
Bodhisattva
Bodhisattva


Joined: 27 Jun 2002
Posts: 1549

PostPosted: Tue Aug 13, 2002 7:13 pm    Post subject: Reply with quote

This will not work if there are spaces in filenames in blah.
proxy wrote:
err, why not just do:

Code:
rm -rf `cat blah`


?

to easy?
Back to top
View user's profile Send private message
proxy
Apprentice
Apprentice


Joined: 20 Apr 2002
Posts: 260
Location: Chantilly, VA

PostPosted: Tue Aug 13, 2002 7:20 pm    Post subject: Reply with quote

do'h! see i knew it was too easy ;)

proxy
Back to top
View user's profile Send private message
Naan Yaar
Bodhisattva
Bodhisattva


Joined: 27 Jun 2002
Posts: 1549

PostPosted: Tue Aug 13, 2002 7:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum