rm

How to remove a file beginning with a dash (in Unix like mode) [duplicate]

吃可爱长大的小学妹 提交于 2019-12-13 10:19:58
问题 This question already has answers here : How do I deal with a filename that starts with the hyphen (-) character? (4 answers) Closed 4 years ago . I have accidentally created a file in GitBash (a Unix like environment) with the name - -l (I have absolutely no idea how I managed to do this in the first place :) Johnny (master #) scipy-tentative-numpy-tutorials $ ls -l total 1 -rw-r--r-- 1 Johnny Administ 956 May 7 16:24 - -l -rw-r--r-- 1 Johnny Administ 562 May 7 16:21 README.md I wish to

Hadoop fs -rm with regular expression

[亡魂溺海] 提交于 2019-12-12 10:26:03
问题 I have a table with 9k partitions, of which I would like to delete about 1200 (which represents 3 days) I would like to combine the hadoop fs -rm and regular expressions for these 3 days, something like pr_load_time=2017070([1-4])(\d+) . The partitions look like this (I want to match only the first two here) pr_load_time=20170701000317 pr_load_time=20170704133602 pr_load_time=20170705000317 pr_load_time=20170706133602 Is something like this possible? I was thinking about matching the

Deleting directories using single liner command

倾然丶 夕夏残阳落幕 提交于 2019-12-12 09:56:37
问题 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? 回答1: rm -r edi edw rm can take an arbitrary number of

rm: cannot remove '–rf': No such file or directory

不羁岁月 提交于 2019-12-12 04:38:14
问题 I have a Bash script that automates creating some SVN folders. In the course of doing so, it creates a temporary directory. When I try to delete that temp directory with the rm -rf command, I get the following error... rm: cannot remove '–rf': No such file or directory It seems to think that "-rf" is a file name. The command works fine on the command line. Here is my script... #!/bin/bash if [ $# -lt 1 ]; then echo "Usage: $0 reponame1 reponame2 ..." else for var in "$@" do REPONAME=$var

How to delete all files with certain suffix before file extension

那年仲夏 提交于 2019-12-11 22:21:59
问题 I was just handed a directory with some 40,000+ images, and the directory includes three versions of every file, which makes it a bear to have to transfer between servers. I'm looking for a way using bash (OSX Terminal) to find and remove (rm) all files, for example, with _web, or _thumb on the end of the filename, just before the .jpg (or .gif, or .png, or .bmp, etc.) extension. So, to be clear, I have the following files: 1.jpg 1_web.jpg 1_thumb.jpg 2.gif 2_web.gif 2_thumb.gif etc. And I

Using rm with extended globbing in node js

自闭症网瘾萝莉.ら 提交于 2019-12-11 07:44:42
问题 I need to do daily cleanup of a folder for my app, so I ve made a bash script (with some help of superuser) to do so. It work well from the console, but it is not interpreted correctly from node. Here the working script: rm ./app/download/!("test1"|"test4"); Which I ve thought would work like this in node.js: var spawn = require('child_process').spawn, PATH = process.argv[1].substr(0, process.argv[1].lastIndexOf('/') + 1), //Get the full path to the directory of the app arg = [PATH +

rm(list = ls()) doesn't work inside a function. Why? [duplicate]

和自甴很熟 提交于 2019-12-11 05:09:00
问题 This question already has an answer here : Why does rm inside a function not delete objects? (1 answer) Closed 2 years ago . I'm trying to create a function that will, simultaneously, clear the workspace and the memory so that, rather than having to type "rm(list = ls()); gc()", I can type just one function. But rm(list = ls()) doesn't work when it's called from within a function. Why? Is there any way around this? > # Let's create an object > x = 0 > ls() [1] "x" > > # This works fine: > rm

Why is shutil.rmtree() so slow?

陌路散爱 提交于 2019-12-10 16:12:57
问题 I went to check how to remove a directory in Python, and was led to use shutil.rmtree(). It's speed surprised me, as compared to what I'd expect from a rm --recursive . Are there faster alternatives, short of using subprocess module? 回答1: The implementation does a lot of extra processing: def rmtree(path, ignore_errors=False, onerror=None): """Recursively delete a directory tree. If ignore_errors is set, errors are ignored; otherwise, if onerror is set, it is called to handle the error with

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

梦想的初衷 提交于 2019-12-10 04:24:39
问题 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? 回答1

Linux 快速删除大量小文件方法

て烟熏妆下的殇ゞ 提交于 2019-12-09 20:24:26
当我们在linux系统中要删除数万或者数十万甚至数百万的文件时使用rm -rf *就不太好用,因为要等待很长一段时间。在这种情况之下我们可以使用linux系统命令rsync来巧妙的处理。rsync实际上用的是替换原理,处理数十万个文件也是秒删。 1. rsync安装,有些系统默认安装有该命令 Ubuntu 系统:sudo apt-get install rsync Fedora 系统:sudo yum install rsync 其他的可以源码安装,到下面的网站下载 http://rsync.samba.org 2. rsync提供了一些跟删除有关的参数 rsync --help | grep delete --del an alias for --delete-during --delete delete extraneous files from destination dirs --delete-before receiver deletes before transfer, not during --delete-during receiver deletes during transfer (default) --delete-delay find deletions during, delete after --delete-after receiver deletes