Re: find -execdir + sed problem
On Thu, Jan 08, 2009 at 12:03:38PM +0200, Micha Feigin wrote: > I'm trying to fix the file suffix on some file in my directories using sed and > find but for some reason sed doesn't match the string in this manner, that is > running > find . -name "*.JPG.jpg" -execdir echo `echo '{}' | sed -e > 's/\(.*\).JPG.jpg/\1.jpg/' -` \; > on a directory with > 2005_10_09-03_05_11.JPG.jpg > prints > 2005_10_09-03_05_11.JPG.jpg > instead of > 2005_10_09-03_05_11.jpg > > any idea what I'm doing wrong? > > find . -type f -exec echo `echo '{}' | tr "[:upper:]" "[:lower:]"` \; I think you will find `echo '{}' | tr "[:upper:]" "[:lower:]"` is being executed by the shell before it executes find > > also fails to convert the file to lower case for some reason (same problem, > doesn't change the case, as if it doesn't see the characters). > > Thanks > > > -- > To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org > with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org > > -- "We got the best workforce in America�in the world." - George W. Bush 12/02/2005 Washington, DC signature.asc Description: Digital signature
Re: find -execdir + sed problem
On Thu, 08 Jan 2009 11:24:27 +0100 Sven Joachim wrote: > On 2009-01-08 11:03 +0100, Micha Feigin wrote: > > > I'm trying to fix the file suffix on some file in my directories using sed > > and find but for some reason sed doesn't match the string in this manner, > > that is running > > find . -name "*.JPG.jpg" -execdir echo `echo '{}' | sed -e > > 's/\(.*\).JPG.jpg/\1.jpg/' -` \; on a directory with > > 2005_10_09-03_05_11.JPG.jpg > > prints > > 2005_10_09-03_05_11.JPG.jpg > > instead of > > 2005_10_09-03_05_11.jpg > > > > any idea what I'm doing wrong? > > The shell does the process substitution before find even sees it: > `echo '{}' | sed -e 's/\(.*\).JPG.jpg/\1.jpg/' -` is substituted by its > output, which is "{}", so you are effectively running > > find . -name "*.JPG.jpg" -execdir echo {} \; > > which is not what you intended. > > > find . -type f -exec echo `echo '{}' | tr "[:upper:]" "[:lower:]"` \; > > > > also fails to convert the file to lower case for some reason (same problem, > > doesn't change the case, as if it doesn't see the characters). > > It does indeed not see them, it only sees {}. > doing find . -type f -exec echo '{}' | tr "[:upper:]" "[:lower:]" \; gives the expected output on the other hand find . -type f -exec echo `echo '{}' | tr "[:upper:]" "[:lower:]"` \; doesn't so trying to execute the command and output it to echo fails. Seems like I'm not clear on the substitution rules in this case > Sven > > -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Re: find -execdir + sed problem
Bob Cox schrieb: On Thu, Jan 08, 2009 at 12:03:38 +0200, Micha Feigin (mi...@post.tau.ac.il) wrote: find . -type f -exec echo `echo '{}' | tr "[:upper:]" "[:lower:]"` \; also fails to convert the file to lower case for some reason (same problem, doesn't change the case, as if it doesn't see the characters). find . -type f | xargs rename y/A-Z/a-z/ If you have file names with special characters in it, e.g. blank characters, better use: find . -type f -print0| xargs -0 rename y/A-Z/a-z/ or find . -type f | while read FILE;do rename y/A-Z/a-z/ "$FILE";done -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Re: find -execdir + sed problem
On Thu, Jan 08, 2009 at 12:03:38 +0200, Micha Feigin (mi...@post.tau.ac.il) wrote: > I'm trying to fix the file suffix on some file in my directories using sed and > find but for some reason sed doesn't match the string in this manner, that is > running > find . -name "*.JPG.jpg" -execdir echo `echo '{}' | sed -e > 's/\(.*\).JPG.jpg/\1.jpg/' -` \; find . -type f | xargs rename s/JPG\.jpg/jpg/ -- Bob Cox. Stoke Gifford, near Bristol, UK. Please reply to the list only. Do NOT send copies directly to me. Debian on the NSLU2: http://bobcox.com/slug/ -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Re: find -execdir + sed problem
On Thu, Jan 08, 2009 at 12:03:38 +0200, Micha Feigin (mi...@post.tau.ac.il) wrote: > find . -type f -exec echo `echo '{}' | tr "[:upper:]" "[:lower:]"` \; > > also fails to convert the file to lower case for some reason (same problem, > doesn't change the case, as if it doesn't see the characters). find . -type f | xargs rename y/A-Z/a-z/ -- Bob Cox. Stoke Gifford, near Bristol, UK. Please reply to the list only. Do NOT send copies directly to me. Debian on the NSLU2: http://bobcox.com/slug/ -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Re: find -execdir + sed problem
On 2009-01-08 11:03 +0100, Micha Feigin wrote: > I'm trying to fix the file suffix on some file in my directories using sed and > find but for some reason sed doesn't match the string in this manner, that is > running > find . -name "*.JPG.jpg" -execdir echo `echo '{}' | sed -e > 's/\(.*\).JPG.jpg/\1.jpg/' -` \; > on a directory with > 2005_10_09-03_05_11.JPG.jpg > prints > 2005_10_09-03_05_11.JPG.jpg > instead of > 2005_10_09-03_05_11.jpg > > any idea what I'm doing wrong? The shell does the process substitution before find even sees it: `echo '{}' | sed -e 's/\(.*\).JPG.jpg/\1.jpg/' -` is substituted by its output, which is "{}", so you are effectively running find . -name "*.JPG.jpg" -execdir echo {} \; which is not what you intended. > find . -type f -exec echo `echo '{}' | tr "[:upper:]" "[:lower:]"` \; > > also fails to convert the file to lower case for some reason (same problem, > doesn't change the case, as if it doesn't see the characters). It does indeed not see them, it only sees {}. Sven -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
find -execdir + sed problem
I'm trying to fix the file suffix on some file in my directories using sed and find but for some reason sed doesn't match the string in this manner, that is running find . -name "*.JPG.jpg" -execdir echo `echo '{}' | sed -e 's/\(.*\).JPG.jpg/\1.jpg/' -` \; on a directory with 2005_10_09-03_05_11.JPG.jpg prints 2005_10_09-03_05_11.JPG.jpg instead of 2005_10_09-03_05_11.jpg any idea what I'm doing wrong? find . -type f -exec echo `echo '{}' | tr "[:upper:]" "[:lower:]"` \; also fails to convert the file to lower case for some reason (same problem, doesn't change the case, as if it doesn't see the characters). Thanks -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org