Visit Our UNIX and Linux User Community


Using "find" and "-exec rm" ... Just no luck :(


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Using "find" and "-exec rm" ... Just no luck :(
# 50  
Old 09-04-2009
You are right, this thread isn't about the standard and you indeed provided an interesting use case where quoting the curly braces has an effect.
It does because quotes are themselves quoted and thus propagated to the exec command.
# 51  
Old 09-14-2009
This was interesting debate. The space is a powerful parser for all shells and has to be dealt with carefully.
This is why unix old-timers use _. Like in file_1 instead of "file 1". It saves you lots of aggravation in script writing.
# 52  
Old 09-20-2009
"gch" has got the right idea. We evolve script which works well on as many platforms as possible. The quoting of "find ... -exec" "{}" or '{}' is not needed in many shells, but still works with the vast majority of modern shells.
# 53  
Old 09-21-2009
Quote:
Originally Posted by methyl
The quoting of "find ... -exec" "{}" or '{}' is not needed in many shells, but still works with the vast majority of modern shells.
The open poster has recognized being mistaken in its initial observations and has failed to provide more details about it so let me rephrase that not to confuse the readers, if you don't mind.
The quoting of "{}" and '{}' is needed in no know shell except with the obscure fish shell interpreter and with it for a reason that has nothing to do with embedded spaces.

Last edited by jlliagre; 09-21-2009 at 06:00 AM.. Reason: typo
# 54  
Old 09-21-2009
jiliagre you cannot draw conclusions about all versions of unix based solely on your own experience. As stated in earlier posts I have seen this problem before which is why I gave the reply which fixed the problem. The quoting of "{}" in unix "find" is well documented though I didn't know that until I looked.
# 55  
Old 09-21-2009
I do not use my experience here but only reasoning. These quotes can't work differently whether the file has embedded spaces or not. I explained it many times but you obviously fail to understand it.
There is no evidence your reply fix anything relating to spaces as the OP back-out. The quoting of "{}" is documented as being possibly required for those hypothetical shells that would interpret them to mean something special. This isn't the OP case who use either bash or dash on Ubuntu.
# 56  
Old 09-21-2009
Hi jiliagre, point taken (at last!). The exact space character in the filename is your issue. We don't know exactly what triggered the fault, only that quoting the braces fixed it. We don't know that the character was a actually a space character.

I do understand the documented normal behaviour of current "find ... -exec" and the passing of one argument via '{}'.

I have had the issue myself in the past with exact space characters in mainstream unix and have now traced the version tree of "find ... -exec" for what it is worth. Due to a parallel issue with "-exec" ("too many forks") I mostly used a construct which avoided "-exec" for large numbers of files. The variant just composed the command line using "normal" shell substitution and then executed the command line in parallel. The current "-exec" does not behave like this.

I too can find no current mainstream unix or Linux with the same variant documented and for completeness I'd be quite interested in any shell construct which interfered with '{}' in this context.

Right fix, wrong reason!
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #212
Difficulty: Medium
According to OSPF, an autonomous system boundary router is a router that is connected by using more than one routing protocol and that exchanges routing information with routers autonomous systems.
True or False?

9 More Discussions You Might Find Interesting

1. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. Shell Programming and Scripting

find . -path "*_nobackup*" -prune -iname "*.PDF" \( ! -name "*_nobackup.*" \)

These three finds worked as expected: $ find . -iname "*.PDF" $ find . -iname "*.PDF" \( ! -name "*_nobackup.*" \) $ find . -path "*_nobackup*" -prune -iname "*.PDF" They all returned the match: ./folder/file.pdf :b: This find returned no matches: $ find . -path "*_nobackup*" -prune... (3 Replies)
Discussion started by: wolfv
3 Replies

4. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

5. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

8. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

9. UNIX for Dummies Questions & Answers

No utpmx entry: you must exec "login" from lowest level "shell"

Hi I have installed solaris 10 on an intel machine. Logged in as root. In CDE, i open terminal session, type login alex (normal user account) and password and i get this message No utpmx entry: you must exec "login" from lowest level "shell" :confused: What i want is: open various... (0 Replies)
Discussion started by: peterpan
0 Replies

Featured Tech Videos