Please be very careful when suggesting the use ofrm -rf without fully knowing the consequences!
In this case before the find command is even being executed, the shell sees a command substitution $(dirname {}).
$(dirname {}) evaluates to a single dot (.), namely the current directory!
So then it executes the find command, which now becomes:
So for every match that find finds it executes this command:
Luckily, on my system in a controlled setting, this leads to the following message..
But who knows if on a different OS you may not be so lucky ...
--
Also: the rm option -i is diametrically opposed to the option -f, using both in the same command gives unspecified results. On my system -f overrules -i so suddenly, by adding the -f option to the OP's -i in the original post, rm does not ask before deleting a file, it just does it.
Last edited by Scrutinizer; 08-27-2016 at 03:16 AM..
Reason: Added posix spec reference
These 2 Users Gave Thanks to Scrutinizer For This Post:
In the bash below I am trying to create sub-directories inside a directory from files with specific .bam extensions. There may be more then one $RDIR ing the directory and the .bam file(s) are trimmed (removing the extension and IonCode_0000_) and the result is the folder name that is saved in... (2 Replies)
I have searched this quite a long time but couldn't find the right method for me to use. I need to assign read write permission to the user for specific directories and it's sub directories and files. I do not want to use ACL. This is for Solaris. Please help. (1 Reply)
If I have 5 files in a directory, what is the best way to remove specific files in it?
For example,
snps.ivg
probes.ivg
Desired output
probes.ivg
probes.txt
all.txt
Basically, removing those files with "snp" in the filename regardless of extension. Thank you :). (2 Replies)
hi,
i have a requirement to delete all the files from all the directories except some specific directories like archive and log.
for example:
there are following directories such as
A B C D Archive E Log F
which contains some sub directories and files. The requirement is to delete all the... (7 Replies)
I need a script which should watch a directory for a file with specific directory.
If it finds a file in directory, it should search for few specific keyword in the file. if the keyword exists, it should trim string from specific column.
The file should be moved to another directory and the a... (8 Replies)
Hi,
I have to find specific files only in the current directory...not in the sub directories.
But when I use Find command ... it searches all the files in the current directory as well as in the subdirectories. I am using AIX-UNIX machine.Please help..
I am using the below command. And i am... (2 Replies)
hi
pls give me a script to compress all directories inside a directory and remove the original uncompressed version...
>>
please also tell the single commmand to uncompress all the directories back...whemn needed (2 Replies)
Ok so I know the title was probably confusing so here goes: I have a tarball (gzipped) that has a nested directory structure . For example:
my.tar.gz (contents)
---
------
---------
------------
---------------
... (2 Replies)