FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 01-08-2009, 09:03 AM
Micha Feigin
 
Default 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-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 01-08-2009, 09:24 AM
Sven Joachim
 
Default 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-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 

Thread Tools




All times are GMT. The time now is 07:30 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org