[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gNewSense-users] Strange find behavior
From: |
Chris F.A. Johnson |
Subject: |
Re: [gNewSense-users] Strange find behavior |
Date: |
Fri, 30 Mar 2007 03:20:47 -0400 (EDT) |
On Fri, 30 Mar 2007, Matthew Flaschen wrote:
This isn't really at all gnewsense-specific, but...:
Can anyone explain this:
find -name "*.c" -exec basename '{}' .c \;
test
test2
find -name "*.c" -exec echo $(basename '{}' .c) \;
../test.c
../test2.c
Shouldn't they do the same thing by definition? I could have sworn the
below command used to work:
find -name "*.c" -exec mv {} $(basename '{}' .c).cpp \;
The basename command is executed and the result is placed on the
command line. What you are running is:
find -name "*.c" -exec echo {} \;
I would expect this to rename test.c test.cpp and test2.c test2.cpp .
Now it changes test.c to test.c.cpp and test2.c to test2.cpp, consistent
with the above.
Why don't you want to use a script? That's the logical way to do it.
Alternatively, if I'm way off track, how can I do this (preferably just
find and basename and without a shell script). I've been reading the
UNIX-Haters Handbook and it's starting to get to me...
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
========= Do not reply to the From: address; use Reply-To: ========
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)