rm

Linux delete file with size 0 [duplicate]

孤者浪人 提交于 2019-12-29 02:22:29
问题 This question already has answers here : How to delete many 0 byte files in linux? (10 answers) Closed 3 years ago . How do I delete a certain file in linux if its size is 0. I want to execute this in an crontab without any extra script. l filename.file | grep 5th-tab | not eq 0 | rm Something like this? 回答1: This will delete all the files in a directory (and below) that are size zero. find /tmp -size 0 -print0 |xargs -0 rm -- If you just want a particular file; if [ ! -s /tmp/foo ] ; then rm

Linux delete file with size 0 [duplicate]

倖福魔咒の 提交于 2019-12-29 02:22:08
问题 This question already has answers here : How to delete many 0 byte files in linux? (10 answers) Closed 3 years ago . How do I delete a certain file in linux if its size is 0. I want to execute this in an crontab without any extra script. l filename.file | grep 5th-tab | not eq 0 | rm Something like this? 回答1: This will delete all the files in a directory (and below) that are size zero. find /tmp -size 0 -print0 |xargs -0 rm -- If you just want a particular file; if [ ! -s /tmp/foo ] ; then rm

Remove symbolic links only from a folder in tcsh [closed]

强颜欢笑 提交于 2019-12-25 18:37:13
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 12 months ago . I need to remove a large number of symbolic links from a folder that has other files which I don't want to remove. Is there any easy way to remove only symbolic links? 回答1: You can use the find(1) command find . -maxdepth 1 -type l -exec rm {} \; -maxdepth 1 is for only scanning current directory. -type l is

rm( ) everything except specific object

大憨熊 提交于 2019-12-24 00:57:24
问题 Does someone have an idea about how can I remove everything in R except one object? Normally, to remove everything I code: rm(list=ls()) So I tried: rm(c(list=ls()-my_object)) but it didn’t work. 回答1: The setdiff() function shows the difference between sets, so we can use this to give the difference between all the objects ( ls() ), and the object you want to keep. For example ## create some objects df <- data.frame() v <- as.numeric() # show everything in environment objects() # [1] "df" "v"

Why does the rm command not remove the file? [closed]

大憨熊 提交于 2019-12-23 17:57:37
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . When i today accessed my Ubuntu 16.04 server and wanted to remove the file "test2" it was simply not deleted! I have used rm test2 as well as rm -f test2 but it still did not delete it as you can read here: root@icinga:~# ls basket desd.save packages scripts src test2 test5 unused root@icinga:~# rm test2 root

How to undo git rm -rf dirname without a first commit?

十年热恋 提交于 2019-12-23 07:49:36
问题 I did: git init git add . git rm -rf dirname Looking at other answsers, git reset --hard HEAD , git checkout -f and git reflog did not work, apparently because there is no HEAD to go back to, nor a commit to get the files back from. Is there a way to get the files back? 回答1: There is no way. Usually, git rm checks the files have already been committed before deleting them, so you don't lose any of your work. However, using -f overrides this check. In short: Don't use -f . Don't touch anything

Unable to remove a special named files in terminal

扶醉桌前 提交于 2019-12-20 04:16:04
问题 Some program makes ta my root directory dummy files such as -1 -2 -3 ... -n I run unsuccessfully rm -1 and too rm "-1" Terminal thinks that -1 is the option. How can you remove the files in terminal? 回答1: You can use rm ./-1 , the ./ refers to the current directory and as the parameter doesn't start with a dash it isn't interpreted as an option. 回答2: As far as I recall adding -- as an option on the commandline will cause the rm command to consider all the remaining arguments literally, so the

remove files when name does NOT contain some words

隐身守侯 提交于 2019-12-18 12:34:26
问题 I am using Linux and intend to remove some files using shell. I have some files in my folder, some filenames contain the word "good", others don't. For example: ssgood.wmv ssbad.wmv goodboy.wmv cuteboy.wmv I want to remove the files that does NOT contain "good" in the name, so the remaining files are: ssgood.wmv goodboy.wmv How to do that using rm in shell? I try to use rm -f *[!good].* but it doesn't work. Thanks a lot! 回答1: This command should do what you you need: ls -1 | grep -v 'good' |

Linux why can't I pipe find result to rm?

≡放荡痞女 提交于 2019-12-17 21:44:23
问题 sorry if this is a noobie question but I can't find a good answer. To find then remove something I can use find . -name ".txt" -exec rm "{}" \; But why can't I just pipe the results to rm like find . -name ".txt" | rm like I would pipe it to grep find . -name ".txt" | grep a I've read from somewhere that rm doesn't take input from stdin and therefore I can't pipe it but what does that mean? When I type in rm a.txt it reads from standard input just like I can grep right? Or is there a

Command line: piping find results to rm

为君一笑 提交于 2019-12-17 17:20:30
问题 I'm trying to work out a command which deletes sql files older than 15 days. The find part is working but not the rm. rm -f | find -L /usr/www2/bar/htdocs/foo/rsync/httpdocs/db_backups -type f \( -name '*.sql' \) -mtime +15 It kicks out a list of exactly the files I want deleted but is not deleting them. The paths are correct. usage: rm [-f | -i] [-dIPRrvW] file ... unlink file /usr/www2/bar/htdocs/foo/rsync/httpdocs/db_backups/20120601.backup.sql ... /usr/www2/bar/htdocs/foo/rsync/httpdocs