Rob van der Heij wrote:
On 2/21/07, John Summerfield <[EMAIL PROTECTED]> wrote:

> cat ifcfg-*4000 | sed 's/.96.70/.96.71/' | >
ifcfg-qeth-bus-ccw-0.0.4010

So you don't mind if 196370 gets changed?


Yes, the period as wildcard has bitten me before and did not make a
good example (and I do escape them when I have to). And I *was*
writing to a new file so there was no real need for the bak files. But
I learned that with bash I cannot write the file that I am reading...

The real gotcha I wanted to point out here was the semantical
difference. With CMS Pipelines this creates a new file 4010 with the
modified contents of 4000. But with bash this does not leave
anything...   as I understand because this pipes into no program and
then redirects the output of that no program. Useless, but
syntactically correct. With CMS Pipelines the ">" is the program, sort
of.

Being in a hurry doing lots of servers (pasting the same thing into
the command line) and you start to suspect all kind of things when it
does not work.

When available (and when I can recall the command) I prefer to use
perl for such things:

perl -i.bak -p -e 's/old string/new string/'  files...

man sed
        sed -i
However, I still prefer explicitly taking a backup if it doesn't exist,
then working on that; if there's a problem I can simply rerun the
command(s).

If you want to do the same to several hosts:
for h in host1 host2
do ssh $h <commandline>
done
The list of hosts can be read from a file with $(cat <some filename>) or
generated in some other way, and if the list is to big for that, then
cat list | while read h ; do ... ; done

I Use the for look to apply maintenance; I run a script on each remote host.



--

Cheers
John

-- spambait
[EMAIL PROTECTED]  [EMAIL PROTECTED]

Please do not reply off-list

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to