[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #31338] find -exec bash -c mv only acts on first thing found by fin
From: |
Robin Anderson |
Subject: |
[bug #31338] find -exec bash -c mv only acts on first thing found by find |
Date: |
Fri, 15 Oct 2010 03:54:30 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Ubuntu/9.10 Chromium/6.0.472.63 Chrome/6.0.472.63 Safari/534.3 |
URL:
<http://savannah.gnu.org/bugs/?31338>
Summary: find -exec bash -c mv only acts on first thing
found by find
Project: findutils
Submitted by: rasyn
Submitted on: Fri 15 Oct 2010 03:54:29 AM GMT
Category: find
Severity: 3 - Normal
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 4.4.2
Fixed Release: None
_______________________________________________________
Details:
Pretty sure this is an issue with find. Works with echo, when they're removed
it does not. mv doesn't work but cp -r does. Might be because find is looking
in a nonexistent dir then thinks its done for some reason. Please edit any
inaccurate parts of this bug submission.
If this is expected behavior, maybe find should output something about it
stopping early.
Confirmed on Ubuntu 9.10 and on Arch both with findutils 4.4.2
Here's a small bash script to demonstrate the issue:
address@hidden:~$ cat findtest.sh
#!/bin/bash
mkdir -p ~/test/find/{1,2,3}
mkdir ~/test/find/1/{a,b,c}
touch ~/test/find/1/a/a.file ~/test/find/1/b/b.file ~/test/find/1/c/c.file
find ~/test/find/1 -iname "*.file" -exec bash -c 'set -x; echo cp "$1"
~/test/find/2/ && echo mv "${1%/*}" ~/test/find/3/' -- {} \;
echo "for some reason this fails (only moves the first)"
find ~/test/find/1 -iname "*.file" -exec bash -c 'set -x; cp "$1"
~/test/find/2/ && mv "${1%/*}" ~/test/find/3/' -- {} \;
echo "but this works (does more than one, ie the last two)"
find ~/test/find/1 -iname "*.file" -exec bash -c 'set -x; cp "$1"
~/test/find/2/ && cp -r "${1%/*}" ~/test/find/3/' -- {} \;
echo "cleanup"
rm -r ~/test/find
address@hidden:~$ bash findtest.sh
+ echo cp /home/abe/test/find/1/a/a.file /home/abe/test/find/2/
cp /home/abe/test/find/1/a/a.file /home/abe/test/find/2/
+ echo mv /home/abe/test/find/1/a /home/abe/test/find/3/
mv /home/abe/test/find/1/a /home/abe/test/find/3/
+ echo cp /home/abe/test/find/1/b/b.file /home/abe/test/find/2/
cp /home/abe/test/find/1/b/b.file /home/abe/test/find/2/
+ echo mv /home/abe/test/find/1/b /home/abe/test/find/3/
mv /home/abe/test/find/1/b /home/abe/test/find/3/
+ echo cp /home/abe/test/find/1/c/c.file /home/abe/test/find/2/
cp /home/abe/test/find/1/c/c.file /home/abe/test/find/2/
+ echo mv /home/abe/test/find/1/c /home/abe/test/find/3/
mv /home/abe/test/find/1/c /home/abe/test/find/3/
for some reason this fails (only moves the first)
+ cp /home/abe/test/find/1/a/a.file /home/abe/test/find/2/
+ mv /home/abe/test/find/1/a /home/abe/test/find/3/
but this works (does more than one, ie the last two)
+ cp /home/abe/test/find/1/b/b.file /home/abe/test/find/2/
+ cp -r /home/abe/test/find/1/b /home/abe/test/find/3/
+ cp /home/abe/test/find/1/c/c.file /home/abe/test/find/2/
+ cp -r /home/abe/test/find/1/c /home/abe/test/find/3/
cleanup
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?31338>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [bug #31338] find -exec bash -c mv only acts on first thing found by find,
Robin Anderson <=