Tagged Questions
1
vote
8answers
96 views
remove content of directory in elegant way
I would like to remove all content of the current working directory.
How to do it in efficient and elegant way?
I have several files, directories and some of them starts with dot, like:
touch .abc; ...
5
votes
3answers
203 views
How do I remove all sub-directories from within a directory?
This question is kind of a phase II to the first question I posted at here
I have a directory that contains a bunch of sub-directories, .zip files, and other random files not contained within a ...
0
votes
2answers
92 views
Remove soft link but not the target
I have a directory that contains a link to another directory that I just created. I would like to remove the link but preserve the directory my link was pointing to. How do I do this?
> mkdir rgac
...
3
votes
2answers
233 views
find flags: -exec rm -rf vs -delete
I thought the flags I mentioned in the question are the same, but I get the following message with the former, but nothing with the latter:
$ find . -mindepth 1 -type d -exec rm -rf {} \;
find: ...
3
votes
2answers
165 views
rm -fr not working
I have a directory that was generated by mistake by an application and this directory has a structure that involves more than 2000 directories, one inside a another, something like:
Directory aaaa ...
5
votes
4answers
431 views
Delete all folders containing files which match pattern
I'm trying to delete all subdirectories of my current working directory which contain a rar file.
My first attempt: find -name *.rar -exec rm -r {}/.. ';' failed because that is not a valid ...
2
votes
2answers
1k views
undo rm -r, restore data
I was playing around with zip and accidentally deleted my /home/ folder (i wanted to delete home/ which got created by unzipping an archive).
I used rm -r /home/instead of rm -r home/ as root...
Is ...
1
vote
1answer
861 views
How do I remove a directory and all its subdirectories?
I'm trying to learn some directory navigagtion with bash and all I know is that
rmdir directoryname
will remove the directory but not if it's containing something. Is there a way to force it to ...
2
votes
3answers
2k views
How can I delete all files with a particular extension in a particular folder?
If I set the current/working directory (navigating to it using cd) to some particular directory and then type:
rm *.xvg
What will this command do? Is it true that the above command will only delete ...
0
votes
1answer
321 views
OSX : rmdir “permission denied” but directory removed
This is a question from a newbie trying to learn UNIX commands.
I was trying to test the rmdir command by removing a test directory located in my Downloads directory. I have read and write rights on ...
3
votes
3answers
195 views
Need to delete a directory with name '~' created accidentally
I don't remember exactly how this directory got created. It's name is ~, the alternative we all use for home diretory. I also see a sticky bit attached with this directory. How shall I delete it? I ...
2
votes
5answers
1k views
Unable to delete directory
On my OS X host, I am having trouble deleting the directory "foo".
mymac:.Trashes joe$ ls
foo
mymac:.Trashes joe$ ls foo/
Ảnh011.jpg Ảnh012.jpg Ảnh013.jpg
mymac:.Trashes joe$ ls -l foo/
ls: ...
3
votes
1answer
1k views
mv file without write permission to the source file
I just realised that I can move a file that I do not own and don't have write permissions on. I have write permissions to the directory, so I am guessing that is why I could move it, but in this ...
3
votes
4answers
833 views
Accidental deletion of /lib directory in Fedora 15
I accidentally deleted the /lib directory on my Fedora 15 machine and I'm not sure how to go about fixing this. Any help in figuring out how to restore the directory along with symbolic links would be ...
1
vote
2answers
968 views
Removing a directory hangs
I'm a non-root user on a shared compile server that mounts /home via NFS from some other host. I have a directory ~/a/b with lots of subdirectories c1,c2,.... I wanted to delete ~/a/b completely, and ...
1
vote
3answers
387 views
shell commands to check & create dir
I am writing a Ruby script inside which I would like to invoke/execute some shell commands.
The shell commands I would like to run should check if a directory named 'tmp' under /var/lib/mysql/ exists ...
5
votes
6answers
405 views
Remove empty directory trees (removing as many directories as possible but no files)
Suppose I have a dir tree like this:
ROOTDIR
└--SUBDIR1
└----SUBDIR2
└----SUBDIR3
I am looking for a command such that when I input:
$ [unknown command] ROOTDIR
The whole ...
3
votes
1answer
450 views
Prevent a subdirectory from getting deleted / enforce a directory structure
imagine the following folder structure
../documents
../documents/templates
I have two user groups:
editors
managers
Users of both groups should be able to
create new files
modify any ...
11
votes
3answers
1k views
Is there any way to prevent deletion of certain files from user owned directory?
Let's say user has Directory1 and it contains File1 File2 CantBeDeletedFile
How to make so the user would never be allowed to delete the CantBeDeletedFile?
If I change the ownership of Directory1 and ...
2
votes
4answers
9k views
How to remove all the files in a directory?
I am trying to remove all files and subdirectories in a directory. I used rm -r to remove all files, but I want to remove all files and subdirectories, excluding the top directory itself.
For ...
8
votes
2answers
1k views
How to remove all empty directories in a subtree?
How can I remove all empty directories in a subtree? I used something like
find . -type d -exec rmdir {} 2>/dev/null \;
but I needs to be run multiple times in order to remove directories ...