The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using a pipe with find .... -exec ... pmallas UNIX for Advanced & Expert Users 1 01-29-2008 05:14 PM
query about find and -exec shriashishpatil UNIX for Advanced & Expert Users 2 04-12-2007 01:16 AM
result of find mpang_ Shell Programming and Scripting 1 05-01-2006 11:00 PM
find and exec big123456 UNIX for Advanced & Expert Users 2 01-02-2006 12:10 PM
find . -type d -exec cd {} \; shimont UNIX for Dummies Questions & Answers 2 11-23-2005 11:42 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 02-19-2008
blued blued is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 4
Lightbulb unexpected pipeline result with find -exec

Hi All,

I probably miss something fundamental here.
I want to rename a bunch of files in subdirectories (that might contain white spaces) with names that are related.

I thought following could do the job:
Code:
find . -name *.sh -exec mv {} $(echo {} | sed -e 's/0/1/g') \;
Now to be able to see the output I generate an echo of the substitutes:
Code:
find . -name *.sh -exec echo {} $(echo {} | sed -e 's/0/1/g') \;
Interestingly echo {} equals echo {} | sed -e 's/0/1/g'.
It looks like the substitution of {} is somehow not done in the order I expected.

If I try the pipelining directly (without ${..}) it generates the right substitution (but for my purpose not usable):
Code:
find . -name *.sh -exec echo {} $(echo "2001" | sed -e 's/0/1/g') \;
Thank you very much for any idea pointing out my mistake,
best,
blued
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:09 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0