find query ?
am 27.01.2008 18:07:49 von onkar
I have number of patches to apply to the Linux kernel. I copied the
patches in the Linix source code directory and fired this command on
bash :
find ./ -name "*.patch" -exec patch -p1 < {} \;
-bash: {}: No such file or directory
find . -maxdepth 1 in the current dir gives me this :
..
../Kbuild
../usr
../include
../i386.patch
../Makefile
../CREDITS
../cfi_annotations.patch
../8250.patch
../crypto
../mm
../x86_64-lite.patch
../sh-lite.patch
../module.patch
../core.patch
../netpoll_pass_skb_to_rx_hook.patch
../README
../scripts
../powerpc.patch
../block
../MAINTAINERS
../x86_64-no_context_hook.patch
../.gitignore
../ipc
../core-lite.patch
../arch
../powerpc-lite.patch
../i386-lite.patch
../sound
../net
../sysrq_bugfix.patch
../lib
../arm-lite.patch
../fs
../mips-lite.patch
../Documentation
../ia64-lite.patch
../security
../kernel
../REPORTING-BUGS
../init
../COPYING
../drivers
../eth.patch
please indicate why
Re: find query ?
am 27.01.2008 18:28:42 von G_r_a_n_t_
On Sun, 27 Jan 2008 09:07:49 -0800 (PST), onkar wrote:
>I have number of patches to apply to the Linux kernel. I copied the
>patches in the Linix source code directory and fired this command on
>bash :
>
> find ./ -name "*.patch" -exec patch -p1 < {} \;
>-bash: {}: No such file or directory
How about: cat *.patch | patch -p1
Grant.
--
http://bugsplatter.mine.nu/
Re: find query ?
am 28.01.2008 00:57:54 von Dan Mercer
"onkar" wrote in message news:7fb0b8e4-0cbb-46b9-a112-5734afac1290@m34g2000hsf.google groups.com...
: I have number of patches to apply to the Linux kernel. I copied the
: patches in the Linix source code directory and fired this command on
: bash :
:
: find ./ -name "*.patch" -exec patch -p1 < {} \;
: -bash: {}: No such file or directory
:
That won't do what you think it does. When bash pasrses the command it
will see yje "< {}" and try to open "{}" as stdin to the subprocess.
-exec does not implicitly run a shell. You could:
find ./ -name "*.patch" -exec bash -c 'patch -p1 < $1' {} {} \;
However, find is unnecessary if maxdepth = 1. Try
for i in *.patch;do patch -p1 < $i;done
Dan Mercer
: find . -maxdepth 1 in the current dir gives me this :
:
: .
: ./Kbuild
: ./usr
: ./include
: ./i386.patch
: ./Makefile
: ./CREDITS
: ./cfi_annotations.patch
: ./8250.patch
: ./crypto
: ./mm
: ./x86_64-lite.patch
: ./sh-lite.patch
: ./module.patch
: ./core.patch
: ./netpoll_pass_skb_to_rx_hook.patch
: ./README
: ./scripts
: ./powerpc.patch
: ./block
: ./MAINTAINERS
: ./x86_64-no_context_hook.patch
: ./.gitignore
: ./ipc
: ./core-lite.patch
: ./arch
: ./powerpc-lite.patch
: ./i386-lite.patch
: ./sound
: ./net
: ./sysrq_bugfix.patch
: ./lib
: ./arm-lite.patch
: ./fs
: ./mips-lite.patch
: ./Documentation
: ./ia64-lite.patch
: ./security
: ./kernel
: ./REPORTING-BUGS
: ./init
: ./COPYING
: ./drivers
: ./eth.patch
:
: please indicate why
Re: find query ?
am 28.01.2008 09:05:42 von Stephane CHAZELAS
On Sun, 27 Jan 2008 17:57:54 -0600, Dan Mercer wrote:
>
> "onkar" wrote in message news:7fb0b8e4-0cbb-46b9-a112-5734afac1290@m34g2000hsf.google groups.com...
> : I have number of patches to apply to the Linux kernel. I copied the
> : patches in the Linix source code directory and fired this command on
> : bash :
> :
> : find ./ -name "*.patch" -exec patch -p1 < {} \;
> : -bash: {}: No such file or directory
> :
>
> That won't do what you think it does. When bash pasrses the command it
> will see yje "< {}" and try to open "{}" as stdin to the subprocess.
> -exec does not implicitly run a shell. You could:
>
> find ./ -name "*.patch" -exec bash -c 'patch -p1 < $1' {} {} \;
>
> However, find is unnecessary if maxdepth = 1. Try
>
> for i in *.patch;do patch -p1 < $i;done
[...]
bash is the one shell for which you need to quote variables in
redirections as it expands wild cards there and is confused by
IFS separators.
find ./ -name "*.patch" -exec bash -c 'patch -p1 < "$1"' {} {} \;
$ echo a > a
$ echo b > '[a]'
$ file='[a]' bash -c 'cat < $file'
a
$ echo x > 'b c'
$ file='b c' bash -c 'cat < $file'
bash: $file: ambiguous redirect
bash is OK when it's called as "sh" or with --posix, or with
POSIXLY_CORRECT in its environment though.
Note that if you want to avoid running one bash instance per
file, you could do:
find ./ -name "*.patch" -exec bash -c '
for file do patch -p1 < "$file"; done' inline {} +
--
Stephane