There are times, when mind is not exactly communicating with your hands – especially with their extremities called fingers….
There are times, when you wish you had some tool that could allow you to edit the mistakes of brain/fingers miscommunication on a number of hosts via some script….
AIX native version of
sed is missing this ability but the “LINUX” version that you can install does it. So if your host has the
/opt/freeware/bin/sed than the following will work for you:
sed -i -e 's/hello/jello/' hello.txt
Which replaces the first located
If you want to replace every
jello than do this instead:
sed -i -e 's/hello/jello/g' hello.txt
But not all of us have this version of
sed installed. What to do? You have
perl. Using it to solve the previous leads to:
perl -pi -e 's/hello/jello/g' hello.txt
Do you know about any other way? If so, please let us now.
Today, I found a gem of simplicity in a shape of a comment. Marcin Wiśnos from unixwear.blogspot.com showed me how to use the tool (
vi) that is synonymous with UNIX to do what I described above. Apparently, there is no need for GNU
# vi +%s/ferris:/ferrisj:/g +wq user "user" 13120 lines, 163733 characters "user" 13120 lines, 163734 characters # grep ferrisj user ferrisj: # grep -p ferrisj user ferrisj: SYSTEM = LDAP registry = LDAP loginretries = 0
It works like a charm, thanks Marcin!