rm

rm cannot delete files starting with “--” [duplicate]

房东的猫 提交于 2019-12-09 13:09:01
问题 This question already has answers here : How to remove files starting with double hyphen? (7 answers) Closed 5 years ago . I have a script that creates files, and sometimes they end up having two dashes at the beginning. Is there any way to delete them? mv doesn't work either. Here is the error I am getting: $ ls --1355509766.jpg $ rm --1355509766.jpg rm: illegal option -- - usage: rm [-f | -i] [-dPRrvW] file ... unlink file $ rm "--1355509766.jpg" rm: illegal option -- - usage: rm [-f | -i]

Deleting directories using single liner command

爱⌒轻易说出口 提交于 2019-12-05 22:14:59
How to remove more than one directory using single command? Is it possible to do it in one liner? If yes, Please help on this. /osmf/mgmt/scheduler>ls -lrt total 22 drwx------ 2 root root 12288 Mar 26 2009 lost+found drwxr-xr-x 4 ctmagent controlm 1024 May 24 2010 ctmagent drwxrwxrwx 3 edwprod edw 1024 Dec 1 09:53 edi drwxrwxrwx 120 edwprod edw 5120 Dec 27 09:37 edw /osmf/mgmt/scheduler> Can I delete edi and edw using a single command? rm -r edi edw rm can take an arbitrary number of arguments, and the -r flag makes it delete directories recursively. Refer to man rm for more details. And, BTW,

Using rm * (wildcard) in envoy: No such file or directory

我们两清 提交于 2019-12-05 08:16:59
I'm using Python and Envoy. I need to delete all files in a directory. Apart from some files, the directory is empty. In a terminal this would be: rm /tmp/my_silly_directory/* Common sense dictates that in envoy, this translates into: r = envoy.run('rm /tmp/my_silly_directory/*') However: r.std_err -> "rm: cannot remove `/tmp/my_silly_directory/*': No such file or directory" Naturally there are alternatives to using envoy in this case, I am simply wondering why it doesn't work. Any clues? On UNIX, it's up to the shell to interpret wildcards like * . If you execute a program and pass an

When should wildcards be inside / outside double quotes?

柔情痞子 提交于 2019-12-04 05:54:22
问题 What is the correct way to use a wild card and a variable to delete many files? This is my variable "$dir" $ echo "$dir" /home/path/to/file Here I have the wild card inside the double quotes, but it does not work: $ rm "$dir/data/ffg_per_product/ffg*" rm: cannot remove `/home/path/to/file/data/ffg_per_product/ffg*': No such file or directory Here I have the wildcard outside the double quotes and it works: $ rm "$dir/data/ffg_per_product/ffg"* And here you can see the files were deleted: $ ls

How to avoid “No such file or directory” Error for `make clean` Makefile target

╄→гoц情女王★ 提交于 2019-12-04 01:21:10
I have a Makefile that defines a .PHONY clean target for cleaning up .o files and executables, that target looks like: ... .PHONY : clean clean: rm $(addprefix $(vq_DIR),$(vq_OBJS)) \ $(addprefix $(vq_DIR),vq) \ $(addprefix $(covq_DIR),$(covq_OBJS)) \ $(addprefix $(covq_DIR),covq) \ $(addprefix $(covq_2_DIR),$(covq_2_OBJS)) \ $(addprefix $(covq_2_DIR),covq_2) \ $(addprefix $(covq_2_DIR),$(test_OBJS)) \ $(addprefix $(covq_2_DIR),test) Everything works as it should, but when some of these files do not exist, rm raises an Error (No such file or directory), and the output says that the Makefile

Restore deleted file not staged in git

萝らか妹 提交于 2019-12-04 00:23:18
问题 I accidentally removed the entire directory of my source code...with a nice rm -r. I know, really bad; but fortunately, I had a git repo in the containing directory. Thus, git has a huge list of unstaged changes of deleted files. For example: "deleted: src/caronmonitor/server.py" How do I get these files back? There is advice all over the web to do: git checkout file or git revert <commit> But as I understand that will restore the file to it's state at the last commit. I don't want to go back

rm cannot delete files starting with “--” [duplicate]

独自空忆成欢 提交于 2019-12-03 16:15:02
This question already has answers here : Closed 5 years ago . How to remove files starting with double hyphen? (7 answers) I have a script that creates files, and sometimes they end up having two dashes at the beginning. Is there any way to delete them? mv doesn't work either. Here is the error I am getting: $ ls --1355509766.jpg $ rm --1355509766.jpg rm: illegal option -- - usage: rm [-f | -i] [-dPRrvW] file ... unlink file $ rm "--1355509766.jpg" rm: illegal option -- - usage: rm [-f | -i] [-dPRrvW] file ... unlink file The usual trick is rm ./--1355509766.jpg Update: here's what man rm has

Can't remove a directory in Unix

只谈情不闲聊 提交于 2019-12-03 07:01:30
问题 I've got a seemingly un-deletable directory in Unix that contains some hidden files with names that start with .panfs . I'm unable to delete it using either of these commands: rm -R <dir> rm -Rf <dir> Does anyone have any suggestions? 回答1: Try to delete it with root user or use sudo , if you are in trouble Use rm -rf dir with root account and it will be deleted, since you should be facing a permissions issue. 回答2: Check with df dir and mount how is your directory mounted and to which file

Unable to remove files recursively from Git

橙三吉。 提交于 2019-12-03 02:40:58
问题 I want to remove all files from Git at ~/bin/. I run git rm -r --cached ~/.vim/* # Thanks to Pate in finding --cached! I get fatal: pathspec '.vim/colors' did not match any files This error messsage suggests me to use the following PATHs, since ~/.vim/** does not work ~/.vim/* # I get the error ~/.vim/*/*/* # This removes files from the index at ~/.vim/folderA/folderB/file1.txt ~/.vim/*/* # similar error as to the first PATH How can you remove all files and subdirectories at ~/.vim from Git?

Can't remove a directory in Unix

房东的猫 提交于 2019-12-02 20:37:58
I've got a seemingly un-deletable directory in Unix that contains some hidden files with names that start with .panfs . I'm unable to delete it using either of these commands: rm -R <dir> rm -Rf <dir> Does anyone have any suggestions? Try to delete it with root user or use sudo , if you are in trouble Use rm -rf dir with root account and it will be deleted, since you should be facing a permissions issue. Check with df dir and mount how is your directory mounted and to which file system it belongs to. Notice that if you use NFS , CIFS/SMB , or some other distributed file system , you could have