Re: find -exec {} help

2007-06-05 Thread Almir Karic
On 6/5/07, Marc Espie [EMAIL PROTECTED] wrote: On Mon, Jun 04, 2007 at 11:45:27PM +0200, Almir Karic wrote: I don't see any -i option documented in the sed manpage. -i on some seds (gsed, ssed, FBSD sed, maybe others) means ''in place'' edit, that feature can be reimplemented with ''sed

find -exec {} help

2007-06-04 Thread David B.
hi, I'm using 3.8, and I hate to bother, but I have spent two days on the net trying to find the answer to this problem. I am using 'find' to batch file a sed search and replace. Sed, of course, outputs to stdout, the problem I am having is finding the correct syntax so that I can change the

Re: find -exec {} help

2007-06-04 Thread Antti Harri
On Mon, 4 Jun 2007, David B. wrote: I am using 'find' to batch file a sed search and replace. Sed, of course, outputs to stdout, the problem I am having is finding the correct syntax so that I can change the extension of the input file to create the new output file. For example: Find .

Re: find -exec {} help

2007-06-04 Thread Bryan Irvine
On 6/4/07, David B. [EMAIL PROTECTED] wrote: hi, I'm using 3.8, and I hate to bother, but I have spent two days on the net trying to find the answer to this problem. I am using 'find' to batch file a sed search and replace. Sed, of course, outputs to stdout, the problem I am having is finding

Re: find -exec {} help

2007-06-04 Thread Almir Karic
Find . -name *.htm -exec 'sed s/old/new/' '{}'.new the above command is probably a sytnax error, due to unterminated -exec (add \; at the end to fix this), that apart that command should look for a command 'sed s/old/new/' (note: it should NOT invoke sed command with s/old/new/ argument).

Re: find -exec {} help

2007-06-04 Thread Stuart Henderson
On 2007/06/04 01:04, David B. wrote: Find . -name *.htm -exec 'sed s/old/new/' '{}'.new From what I've read, I should be able to use the '{}' as a global replace; you pass {} to the shell as part of the filename to redirect the output from find(1) to, it is not seen by find(1) at all (and

Re: find -exec {} help

2007-06-04 Thread Marc Espie
On Mon, Jun 04, 2007 at 12:30:49AM -0700, Bryan Irvine wrote: On 6/4/07, David B. [EMAIL PROTECTED] wrote: hi, I'm using 3.8, and I hate to bother, but I have spent two days on the net trying to find the answer to this problem. I am using 'find' to batch file a sed search and replace. Sed,

Re: find -exec {} help

2007-06-04 Thread Hannah Schroeter
Hello! On Mon, Jun 04, 2007 at 02:01:12PM +0200, Marc Espie wrote: [...] Don't use for loops with find results, they do not scale well. Also, beware of spaces in file. For this kind of thing, I generally use 'while read' find . -type f -name \*.htm -print|while read f; do sed s/old/new $f

Re: find -exec {} help

2007-06-04 Thread Martin Schröder
2007/6/4, Marc Espie [EMAIL PROTECTED]: Don't use for loops with find results, they do not scale well. Also, beware of spaces in file. For this kind of thing, I generally use 'while read' Use xargs(1) Best Martin

Re: find -exec {} help

2007-06-04 Thread Hannah Schroeter
Hello! On Mon, Jun 04, 2007 at 03:26:28PM +0200, Martin Schrvder wrote: 2007/6/4, Marc Espie [EMAIL PROTECTED]: Don't use for loops with find results, they do not scale well. Also, beware of spaces in file. For this kind of thing, I generally use 'while read' Use xargs(1) For that case, it

Re: find -exec {} help

2007-06-04 Thread Almir Karic
A completely safe solution would be writing a small script: #! /bin/sh exec sed s/old/new/ $1 $1.new and using find . -type f -name \*.htm -exec /path/to/script {} \; or find . -type f -name \*.htm -print0 | xargs -0 -L 1 -r /path/to/script ...-exec sh -c 'something with $1' {} \; is fully

Re: find -exec {} help

2007-06-04 Thread Tom Van Looy
I think this is also correct: find . -name '*.htm' -exec cp '{}' '{}'.new \; \ -exec sed -i s/old/new/ '{}'.new \; Hannah Schroeter wrote: Hello! On Mon, Jun 04, 2007 at 02:01:12PM +0200, Marc Espie wrote: [...] Don't use for loops with find results, they do not scale well. Also, beware

Re: find -exec {} help

2007-06-04 Thread Hannah Schroeter
Hello! On Mon, Jun 04, 2007 at 06:27:41PM +0200, Almir Karic wrote: A completely safe solution would be writing a small script: #! /bin/sh exec sed s/old/new/ $1 $1.new and using find . -type f -name \*.htm -exec /path/to/script {} \; or find . -type f -name \*.htm -print0 | xargs -0 -L 1 -r

Re: find -exec {} help

2007-06-04 Thread Almir Karic
...-exec sh -c 'something with $1' {} \; is fully safe as well. sh -c 'echo foo$1bar' baz - foobar Seems not. a typo, sorry, it should be sh -c 'echo foo$1bar' -- baz i am cheating tho, and have sh symlinked to bash. -- almir

Re: find -exec {} help

2007-06-04 Thread Hannah Schroeter
Hi! On Mon, Jun 04, 2007 at 06:54:20PM +0200, Tom Van Looy wrote: I think this is also correct: find . -name '*.htm' -exec cp '{}' '{}'.new \; \ -exec sed -i s/old/new/ '{}'.new \; I don't see any -i option documented in the sed manpage. Kind regards, Hannah.

Re: find -exec {} help

2007-06-04 Thread Hannah Schroeter
Hi! On Mon, Jun 04, 2007 at 07:49:08PM +0200, Almir Karic wrote: ...-exec sh -c 'something with $1' {} \; is fully safe as well. sh -c 'echo foo$1bar' baz - foobar Seems not. a typo, sorry, it should be sh -c 'echo foo$1bar' -- baz This works indeed. But better use the additional quotes

Re: find -exec {} help

2007-06-04 Thread Marc Espie
On Mon, Jun 04, 2007 at 02:25:00PM +0200, Hannah Schroeter wrote: Hello! On Mon, Jun 04, 2007 at 02:01:12PM +0200, Marc Espie wrote: [...] Don't use for loops with find results, they do not scale well. Also, beware of spaces in file. For this kind of thing, I generally use 'while read'

Re: find -exec {} help

2007-06-04 Thread terry tyson
On 6/4/07, Hannah Schroeter [EMAIL PROTECTED] wrote: Hi! On Mon, Jun 04, 2007 at 06:54:20PM +0200, Tom Van Looy wrote: I think this is also correct: find . -name '*.htm' -exec cp '{}' '{}'.new \; \ -exec sed -i s/old/new/ '{}'.new \; I don't see any -i option documented in the sed

Re: find -exec {} help

2007-06-04 Thread Almir Karic
\ This works indeed. But better use the additional quotes around $1. Just get used to them, because $1 could contain IFS characters. true, but in this case it doesn't really matter how shell splits words :) i am cheating tho, and have sh symlinked to bash. Why? i learnt to use bash,

Re: find -exec {} help

2007-06-04 Thread Marc Espie
On Mon, Jun 04, 2007 at 11:45:27PM +0200, Almir Karic wrote: I don't see any -i option documented in the sed manpage. -i on some seds (gsed, ssed, FBSD sed, maybe others) means ''in place'' edit, that feature can be reimplemented with ''sed '' file new_file; mv -g new_file file'' (it

Re: find -exec {} help

2007-06-04 Thread Hannah Schroeter
Hello! On Mon, Jun 04, 2007 at 11:45:27PM +0200, Almir Karic wrote: \ This works indeed. But better use the additional quotes around $1. Just get used to them, because $1 could contain IFS characters. true, but in this case it doesn't really matter how shell splits words :) Proactive security

Re: find -exec {} help

2007-06-04 Thread Hannah Schroeter
Hello! On Mon, Jun 04, 2007 at 04:37:17PM -0500, terry tyson wrote: On 6/4/07, Hannah Schroeter [EMAIL PROTECTED] wrote: On Mon, Jun 04, 2007 at 06:54:20PM +0200, Tom Van Looy wrote: I think this is also correct: find . -name '*.htm' -exec cp '{}' '{}'.new \; \ -exec sed -i s/old/new/