Strange sed results
Hi Everyone.
Long time since I posted... I have an odd issue that I am running into. My objective is to insert the following lines at the end of /etc/inputrc on an RHES box: Code:
# alternate mappings for "page up" and "page down" to search the history The original version I was using looked like this: Code:
mv /etc/inputrc /tmp/inputrc.orig Code:
mv /etc/inputrc /tmp/inputrc.orig As I mentioned earlier in the post, this was working on 'newer' RHES 5 and up but I have the misfortune of having to support some older RHES 4 boxes in a closed lab. This particular box is an RHES 4u6. Anyone got any suggestion on how I find out what's happening? Also if some wiser sed heads can give me a more elegant version it would be appreciated. Thanks in Advance! Michael E |
How about this:
Code:
echo '# alternate mappings for "page up" and "page down" to search the history |
Quote:
That has to be at the end so it's not just concatenation that has to happen but more of an "insert-between". Thanks for your suggestion though! |
Hi,
the issue that I encountered with your 'sed' was that it swallowed the backslashes. This one worked for me Code:
sed -i.orig '/$endif/ {i\ Code:
$ sed --version The -i.orig option will create a backup file before 'sed' makes any changes to the original file. This makes the preceding 'mv' redundant. If something goes wrong then you can restore the original file that has been backupped to /etc/inputrc.orig. |
Thanks crts!
That worked perfectly on the hosts I've tried thus far. The -i.orig is an elegant method rather than my crude mv. Kudos and Regards, Michael E |
All times are GMT -5. The time now is 09:54 AM. |