Prev: /var/log/kdm.log file now 7.3GB HELP
Next: almost luck
From: Rockinghorse Winner on 25 Dec 2009 20:27 David Bolt <blacklist-me(a)davjam.org> writes: >On Friday 25 Dec 2009 02:39, while playing with a tin of spray paint, >Moe Trin painted this mural: >> On Thu, 24 Dec 2009, in the Usenet newsgroup alt.os.linux.suse, in article >> <muadnZisCcijiKnW4p2dnAA(a)giganews.com>, Rockinghorse Winner wrote: >> >>>What am I missing here? >>> >>>[8600:/home/rh]$ find . -iname *.mp3 >>>find: paths must precede expression: 02_-_Moonlight.mp3 >> >> find . -iname \*.mp3 >Or wrap the *.mp3 in quotes, as suggested by Ray. >>>find rh -iname *.mp3 >> >> Not exactly sure - it should barf the same way. You're seeing >> a shell expansion of the star character. >The shell expands the * if there's a match. If not, it passes it to >find as-is. So, as there's no mp3s in /home , there is no expansion >and so that one works as expected. However, there do appear to be more >than one in /home/rh and so the shell expands it to pass them all as >arguments, and so the command fails. >Regards, > David Bolt Thanks for your and the previous posters' explanations. Best to you and yours. -- Powered by Linux 2.6.31.6-166 Fedora 12 In rotation: Pacific Ocean Blue (D. Wilson) 2.6.31.5-0.1 OpenSUSE 11.2 "Hug your cat today" 2.6.24-16 Mint Elyssa
From: Rockinghorse Winner on 25 Dec 2009 20:32 houghi <houghi(a)houghi.org.invalid> writes: >ray wrote: >> On Thu, 24 Dec 2009 19:28:30 -0600, Rockinghorse Winner wrote: >> >>> What am I missing here? >>> >>> [8600:/home/rh]$ find . -iname *.mp3 >> >> try this: >> find . -iname "*.mp3" >That is indeed the way to do it with find. >I never botherd to find out why, because it works if you do add the "" >around it. Even if someone would explain exactly why, I would most >likely not understand it anyway, it won't change anything and will >confuse more then resolve. Obviously that goes only for me. >>> find: paths must precede expression: 02_-_Moonlight.mp3 Usage: find [-H] >>> [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] >>> [expression] >>> >>> [8600:/home/rh]$ cd .. >>> >>> [8600:/home]$ find rh -iname *.mp3 >To confuse you even more, try `find . -iname *.mp3` in that directory >and it works. ;-) You're right. It works. And it confuses me even more. :) -- Powered by Linux 2.6.31.6-166 Fedora 12 In rotation: Pacific Ocean Blue (D. Wilson) 2.6.31.5-0.1 OpenSUSE 11.2 "Hug your cat today" 2.6.24-16 Mint Elyssa
From: Eef Hartman on 29 Dec 2009 06:48 Rockinghorse Winner <rwinner(a)8600.com> wrote: >>To confuse you even more, try `find . -iname *.mp3` in that directory >>and it works. ;-) > > You're right. It works. And it confuses me even more. :) The thing is, *.mp3 gets evaluated (by the shell) _before_ find even gets the commandline, so the actual command you're giving is: find <path> -name <all the .mp3's in the CURRENT dir, NOT in the path to search> With either "" or just a simple \ in front of the * you tell the shell: leave this filename "as is", do NOT evaluate it yourself. So then "find" _does_ get the * and will evaulate it itself. With commands like tar (extracting FROM a tar file) or scp (at the "remote side" you also need to protect "characters, special to the shell" and for the same reason. -- ******************************************************************* ** Eef Hartman, Delft University of Technology, dept. SSC/ICT ** ** e-mail: E.J.M.Hartman(a)tudelft.nl - phone: +31-15-278 82525 ** *******************************************************************
From: Eef Hartman on 29 Dec 2009 06:49 Moe Trin <ibuprofin(a)painkiller.example.tld.invalid> wrote: > Not exactly sure - it should barf the same way. You're seeing > a shell expansion of the star character. Newer shells DO leave the * alone when there are NO matching files. So probably the OP changed to a directory in which there are no ..mp3 files present. -- ******************************************************************* ** Eef Hartman, Delft University of Technology, dept. SSC/ICT ** ** e-mail: E.J.M.Hartman(a)tudelft.nl - phone: +31-15-278 82525 ** *******************************************************************
From: Rockinghorse Winner on 29 Dec 2009 10:13
Eef Hartman <E.J.M.Hartman(a)tudelft.nl> writes: >Rockinghorse Winner <rwinner(a)8600.com> wrote: >>>To confuse you even more, try `find . -iname *.mp3` in that directory >>>and it works. ;-) >> >> You're right. It works. And it confuses me even more. :) >The thing is, *.mp3 gets evaluated (by the shell) _before_ find even >gets the commandline, so the actual command you're giving is: > find <path> -name <all the .mp3's in the CURRENT dir, NOT in the >path to search> >With either "" or just a simple \ in front of the * you tell the >shell: leave this filename "as is", do NOT evaluate it yourself. >So then "find" _does_ get the * and will evaulate it itself. >With commands like tar (extracting FROM a tar file) or scp (at the >"remote side" you also need to protect "characters, special to the >shell" and for the same reason. >-- >******************************************************************* >** Eef Hartman, Delft University of Technology, dept. SSC/ICT ** >** e-mail: E.J.M.Hartman(a)tudelft.nl - phone: +31-15-278 82525 ** >******************************************************************* Thanks for expanding on previous explanations. Now, I believe I understand fully what is going on. Best to you and yours. -- Powered by Linux 2.6.31.6-166 Fedora 12 In rotation: Pacific Ocean Blue (D. Wilson) 2.6.31.5-0.1 OpenSUSE 11.2 "Hug your cat today" 2.6.24-16 Mint Elyssa |