3
votes
1answer
39 views

Is there a single '03 registered UNIX which can't do rm — -foo at this point?

I'm trying to dispel this uncertainty I have about the use of the double-dash (two hyphens, --) as an end of options delimiter(as opposed to a long option prefix). It's possible some confusion arose ...
1
vote
3answers
45 views

How to remove all FIFO files with a shell command

I can't find a shell command to remove all the FIFO files inside a directory. In fact, for the removal of directories, the rm command offers the options -d, --dir, but for FIFOs it offers no option. ...
1
vote
1answer
61 views

Prevent active file removal on an NFS filesystem

I clear my logs using following script - find "." -mtime 1 -type f -print0 | xargs -0 rm -rf But it deletes the active files also and creates .nfs… files instead. Is there any way to prevent ...
1
vote
3answers
161 views

Delete files with same name at the end of the file

Delete files with same name at the end of the file i have a lot of files in my folder and sub directories like ajax_hostel_room_master.php.php class_hostel_registration.php.php ...
1
vote
2answers
173 views

Free disk space from a JBoss log file which is still being written to

Is there any locking on the content, imposed by the process if at all the process is using the file. We host a JBoss app server on a RHEL 6.4 OS and due to the disk space constraints we have decided ...
2
votes
2answers
511 views

delete old log files except the last one (alphanumerically sorted)

I have a number of log files in the form: log.2014-02-19-10_24_22 I.e. log.YYYY-MM-DD-H24_MI_SS The date that's part of the log file's name is when the log file was first created. So at any given ...
-1
votes
4answers
84 views

Using 'find' to create text file, and later deleting files listed

I'm trying to use find to create a text file with the result. And then later be able to delete files, based on that list. I'm using find /volume1/video/ -iname "sample" to give me the results. How do ...
2
votes
2answers
153 views

delete directory with special character in filename

I have these tricky directories that I can't figure out how to delete. If I run ls -ld * I get… drwxrwxr-x 7 user1 taskfmri 2048 Jan 22 15:26 857263 drwxrwx--- 4 user2 ...
2
votes
2answers
56 views

Process each line from text file and delete related files from disk

I used the find command to find several files and folders and output them to a text file like so: nohup find /oradba -name '*soapr*' 2>/dev/null >find_soapr_db40.txt & So instead of ...
3
votes
2answers
324 views

grep string from contents of file command then delete file

I have a peculiar problem I need help with. I have a large batch of .docx files where a certain number of them are junk. I know how to identify these files from the file command, as they contain the ...
3
votes
3answers
1k views

How to delete 2 months back files in unix

Say I have below log files, AA_XX_20130719185428.log exec_xxx_cpb_20130712182453.log 13122013121327_AR_INC_DOBC_1.dprf.log 24122013_masterscript.LOG Date part contains both date and time. I want ...
1
vote
3answers
557 views

Remove all *.mp4 and *.zip but some files

In one of my programs I call a bash command to remove all files in the directory, but some: bash -c shopt -s extglob shopt -s nullglob rm /path/to/directory/!("file1" | "file2") Which for what I ...
3
votes
1answer
152 views

How can there be a directory named `~`?

I was trying to test out this buggy/new tool to see how it works, and it prompted me to choose a directory to use for stuff I am doing. From the directory ~/Code/indep, I typed in ...
3
votes
2answers
2k views

Scripting `rm` and `rm -i`

I want to create a script that whenever there are more than three files being removed, it invokes rm -i by default. I know it will go in initialization files but can't seem to get it working. So far: ...
25
votes
1answer
1k views

Does 'rm .*' ever delete the parent directory?

The expression .* is expanded by bash to include the current and parent directories: $ ls -la total 2600 drwxrwxrwx 2 terdon terdon 2162688 Sep 10 16:22 . drwxr-xr-x 142 terdon terdon 491520 Sep ...
1
vote
8answers
133 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; ...
6
votes
3answers
2k 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
3answers
427 views

Safe Directory Delete

I alias rm to rm -i so that when I mistype file* as file * I get prompted before accidentally deleting files I didn't intend to delete. Is there an equivalent idiom for directories? In particular, ...
10
votes
2answers
1k views

Interactively deleting files from a list

I'd like to remove a list of files and be asked for confirmation. The list is in the list.txt file. Why the following command doesn't work properly? while read i; do rm -i $i; done < list.txt ...
11
votes
3answers
4k views

Make `rm` move to trash

Is there a Linux script / application which, instead of deleting files, moves them to a special “trash” location? I’d like this as a replacement for rm (maybe even aliasing the latter; there are pros ...
3
votes
3answers
13k 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 ...
2
votes
1answer
3k views

How can I delete a hidden folder?

I want to delete many configuration folder in my home user folder but I can't figure out how to delete them. How can I delete a hidden folder?
4
votes
3answers
1k views

Remove many many many files from a folder

I have a folder with 137795 files in it. I need to delete all of them. When I run rm * I get -bash: /bin/rm: Argument list too long. How do I get past this error?
1
vote
3answers
1k 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 ...
6
votes
6answers
1k 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 ...
4
votes
3answers
755 views

Delete matching file from every subfolder of current dir

I used this one to copy file in every dir: find -type d -maxdepth 1 -print0 | xargs -0 -n1 cp .htaccess Now i need to do reverse one and delete file with matching name from every sub directory of ...
3
votes
3answers
2k views

Delete files based on year

I need to delete all files in a directory that were created in 2009. What command can I use to do that?
2
votes
2answers
1k views

How to remove the directory a symbolic link links to plus the symbolic link?

Say a is a symbolic link to b. I am looking for a simple command to remove both a and b at once that does not require me to know about b.
11
votes
8answers
2k views

How do I delete everything in a directory?

I'm sorry for asking such a basic question: How do I delete everything in a directory, including hidden files and directories? Right now, I use the following: rm -rf * rm -rf .*
42
votes
7answers
7k views

How do I delete a file whose name begins with “-” (hyphen a.k.a. dash or minus)?

How do you remove a file whose filename begins with a dash (hyphen or minus) -? I'm ssh'd into a remote OSX server and I have this file in my directory: tohru:~ $ ls -l total 8 -rw-r--r-- 1 me ...
1
vote
2answers
5k views

Delete files in a directory that match a regexp, using a Mac terminal

How do I delete files in a directory that match a given regexp, or a similar solution, using a Mac terminal?