LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 01-01-2008, 07:04 PM   #1
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
find with -exec: no command output


When trying to run the rename command on a file tree using find, I'm not getting any output from the rename command itself. The command does it's job, but nothing is output to stdout.

Let's say I run this:

find . -exec rename "s/[\']//g" '{}' \;

which removes any and all apostrophes from the filenames. It works, but there's no output from rename to tell me which files it actually changed. Needless to say, this is rather annoying. On the other hand, I can do this:

find . | rename "s/[\']//g"

Which does show me the output. But then I run across a different problem. If the rename function changes the name of a folder first, then any files nested under that folder fail to get changed. I then have to run the command a second time.

This is the first time I've tried to use the -exec option of find. Is this its regular behavior? Is there any way to force find to show me the output of the executed command?
 
Old 01-01-2008, 09:03 PM   #2
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,476

Rep: Reputation: 156Reputation: 156
Perhaps:

find . -exec rename -v "s/[\']//g" '{}' \;

--------------------------
Steve Stites
 
Old 01-02-2008, 03:55 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Original Poster
Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
D'oh! Stupid me.

I completely forgot that I had aliased 'rename' to 'rename -v' a while back, so I mistakenly thought that the verbose output was the standard behavior. It figures I'd make myself look stupid asking this question.

Thanks anyway.
 
Old 01-02-2008, 04:27 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,127

Rep: Reputation: 985Reputation: 985Reputation: 985Reputation: 985Reputation: 985Reputation: 985Reputation: 985Reputation: 985
Not only that - don't get too used to the regex usability if you use different distros.
Try a "which rename" ...
 
Old 01-02-2008, 07:33 PM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Original Poster
Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
I'm not sure I follow you syg00. The rename utility I'm using is one of the basic perl tools, and should be available just about anywhere perl is installed ('rename' is actually a link to 'prename'). If other distros or installations use something different I'm sure I'd discover it fairly quickly and learn to adapt. Besides, I only use Debian on my home systems, so it's not like I'm going to run into trouble anytime soon.

My problem here was just forgetfulness and a stupid assumption on my part.
 
Old 01-03-2008, 01:53 AM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,127

Rep: Reputation: 985Reputation: 985Reputation: 985Reputation: 985Reputation: 985Reputation: 985Reputation: 985Reputation: 985
Quote:
Originally Posted by David the H. View Post
The rename utility I'm using is one of the basic perl tools, and should be available just about anywhere perl is installed
If you believe that, you'd better stick to Debian derived distros ...
Quote:
If other distros or installations use something different I'm sure I'd discover it fairly quickly and learn to adapt.
I'm sure you would - however it can be a shock to find a favourite "feecher" missing though ... as you discovered.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find with -exec argument - not giving proper output..how to find... hinetvenkat Linux - Server 4 01-25-2010 06:19 AM
does "find -exec" not recognize built-in command? yaru22 Linux - General 1 06-30-2006 10:35 AM
using multiple -exec commands in a single find command? Bluemilk Linux - Newbie 4 03-19-2006 10:46 AM
redhat 9.0 how to use the command 'find' with the action -exec arvin_shu Linux - Newbie 3 11-30-2005 07:09 AM
php: output the result of exec( $command ) zovres Programming 6 08-27-2004 06:41 PM


All times are GMT -5. The time now is 11:48 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration