listing and deleting directories
+2
Christopher
parvathy
6 posters
listing and deleting directories
how to list and delete more than one directories in one single command??????
parvathy- Posts : 7
Points : 15
Join date : 2010-02-26
Re: listing and deleting directories
- Code:
$ ls -d */ | xargs rm -r
the above command will delete only the directories in the present directory without deleting files.
Re: listing and deleting directories
hey......thanks
parvathy- Posts : 7
Points : 15
Join date : 2010-02-26
Re: listing and deleting directories
what does xagrs stands for. I know rm is for remove command what does - r do
Navitha- Posts : 14
Points : 24
Join date : 2010-02-26
Re: listing and deleting directories
xargs is used to pass more than one arguments to a command. In this example, the output of ls command is passed as argument to rm. Each file or directory in the output of ls command will be passed as arguments to rm individually.
Re: listing and deleting directories
Hey thanks, I understood the xargs command what about the -r command.
Navitha- Posts : 14
Points : 24
Join date : 2010-02-26
Re: listing and deleting directories
-r or -R is used to recursively remove the files or directories.
urvershi- Posts : 21
Points : 70
Join date : 2010-02-26
xargs
xargs is to pass more than one arguements..
does it mean that if there is only one directory being passed then xargs is not required??
can you give some more examples!
does it mean that if there is only one directory being passed then xargs is not required??
can you give some more examples!
jeeva- Posts : 50
Points : 93
Join date : 2010-03-04
Re: listing and deleting directories
actually both -r and -R recursively removes a directory but wats the difference!!!
jeeva- Posts : 50
Points : 93
Join date : 2010-03-04
Re: listing and deleting directories
i dont think so. Even if the output of ls is a single value, it wont work. if u r using a command('ls') which produce list of values, u have to use xargs.
Re: listing and deleting directories
by mistake i have deleted all directories ... how to recover those.?...........
anand- Posts : 55
Points : 70
Join date : 2010-02-26
Age : 36
Re: listing and deleting directories
I think it is not possible to recover deleted files if u r in multiuser mode. i recommend adding more immunity to ur files which can prevent accident deletion of files.
for adding immunity
for removing immunity
anyways... these commands will work only for root user.
for adding immunity
- Code:
chattr +i file
for removing immunity
- Code:
chattr -i file
anyways... these commands will work only for root user.
Similar topics
» deleting non-empty directories??
» deleting a particular line in a file
» copying file contents across directories
» [SYNTAX] Working with Directories and Files
» to find empty files
» deleting a particular line in a file
» copying file contents across directories
» [SYNTAX] Working with Directories and Files
» to find empty files
Permissions in this forum:
You cannot reply to topics in this forum
|
|