Last active
August 12, 2016 12:45
-
-
Save cejojohn/683c58789e1c4f87ea1ca8df2c54cd85 to your computer and use it in GitHub Desktop.
Append characters at the end of each line. You can also append characters like new line or carriage return. I used in rsyslog configurations where I had scripted and created a set of remote syslog reception for a set of switches and needed the add the ending character for the if condition of syslog.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sed -e 's/$/string after each line/' -i filename | |
#So for me I needed to add "& ~" at the end of all lines in my file so that I could copy it to rsyslog.conf to receive logs from the network devices. | |
#Initial File: | |
if $fromhost-ip == '1.1.1.1' then /var/log/Switches/Switch1.log | |
if $fromhost-ip == '2.2.2.2' then /var/log/Switches/Switch2.log | |
. . . . . . | |
. . . . . . | |
. . . . . . | |
#So I need to add "& ~" and a new line character to the next line of all the lines. | |
sed -e 's/$/\n\& \~\n/' syslogfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment