Sponsored Content
Top Forums Shell Programming and Scripting help needed with shell script to append to the end of a specific line in a file on multiple servers Post 302529598 by momin on Thursday 9th of June 2011 06:05:10 PM
Old 06-09-2011
help needed with shell script to append to the end of a specific line in a file on multiple servers

Hi Folks,

I was given a task to append three IP's at the end of a specific (and unique) line within a file on multiple servers.

I was not able to do that with the help of a script. All I could was:

for i in server1 server2 server3 server4
do
ssh $i
done

I know 'sed' could be used to append to the end of the line but how to save that and replicate on all servers in the list?

Original File
-----------

#cat /etc/ftpd/ftpaccess
greeting brief
log commands
log transfers
class users real 172.25.6.148 172.25.197.148 172.25.52.100 172.21.56.75 172.21.54.159 172.25.2.25 172.25.2.26 172.25.119.132 172.25.119.133 172.25.119.134 172.25.119.135 172.25.183.132 172.25.183.133 172.25.183.134 172.25.183.135
banner /etc/ftpd/banner.txt

(each server had different IP's in the line starting with: class
users real .....):

Change required:
----------------

Append "172.21.105.99 172.21.105.100 172.21.105.101" at the end of line starting with text:'class users real')


Any help will be appreciating in how would you gurus would accomplish this task with the help of a script / scripted-command.

Thanks in advance
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append text at end of the first line in a file

Hi I need to append some text @ end of the first line in a file. like myfile.txt list = a,b,c list.a=some.. I give the arg "d" . now it append at end of first line list=a,b,c,d list.a=some... Please help me out this (7 Replies)
Discussion started by: catgovind
7 Replies

2. Shell Programming and Scripting

append a character at end of each line of a file

Hi, i want to append a character '|' at end of each line of a file abc.txt. for example if the file abc.txt conatins: a|b|c 1|2|33 w|2|11 i want result file xyz.txt a|b|c| 1|2|33| w|2|11| I know this is simple but sumhow i am not able to reach end of line. its urgent, thanks for... (4 Replies)
Discussion started by: muaz
4 Replies

3. Shell Programming and Scripting

Line Count and Append it to the end of the file.

Hi, I want to get a Line count of a file and append that at the end of the file. The Line count should not include the Headers : ------------------ COL1,COL2,COL3 123,abc,011 111,abd,0212 Record Count: 2 ------------------- Thanks. (7 Replies)
Discussion started by: smc3
7 Replies

4. Shell Programming and Scripting

How can I append a string at the end of a line in a file

Hi, guys. I have one question: I have a file called "group", the contents of it is below: ******************************** ... test:x:203: sales:x:204: repair:x:205: research:x:206:brownj ... *********** Now I want to add string ",sherrys" at the end of "research:x:206:brownj", so... (5 Replies)
Discussion started by: daikeyang
5 Replies

5. Shell Programming and Scripting

shell script to read a line in gps receiver log file and append that line to new file

Hi, I have gps receiver log..its giving readings .like below Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GPSD,R=1 $GPGSV,3,1,11,08,16,328,40,11,36,127,00,28,33,283,39,20,11,165,00*71... (3 Replies)
Discussion started by: gudivada213
3 Replies

6. Shell Programming and Scripting

How to append value at first line of CSV file using shell script?

I have an issue where I need to append a value at the last of the csv, I have created a shell script and it is appending the columns at the last but it is appending at all lines, and my requirement is specific to just append at the 1st line. Have a look and suggest, (7 Replies)
Discussion started by: anujrichhariya
7 Replies

7. Shell Programming and Scripting

Append a string at the end of every line in a file

Hi Friends, I have a file with many lines as shown below. /START SAMPLE LINE/ M:\mmarimut_v6.4.0_pit_01\java\build.xml@@\main\v6.4.0_pit_a M:\mmarimut_v6.4.0_pit_01\port\Post.java@@\main\v6.4.0_pit_a M:\mmarimut_v6.4.0_pit_01\switchview\View.java@@\main\v6.4.0_pit_a /END SAMPLE LINE/ I... (1 Reply)
Discussion started by: nmattam
1 Replies

8. Shell Programming and Scripting

Append the end of each line in a file with a given string

Hi friends, I have a file containing many lines as follows. M:\mmarimut_v6.4.0_pit_01\java\build.xml@@\main\v6.4.0_pit_a M:\mmarimut_v6.4.0_pit_01\ADBasicView.java@@\main\v6.4.0_pit_a I would like to append the string "\0" at the end of each line in the file. The output should look... (10 Replies)
Discussion started by: nmattam
10 Replies

9. Shell Programming and Scripting

SED and Solaris Append line to the end of File does not work

Hello, I have to add a new line at the end of a File on Solaris-System: I think my script should be right, because I evaluated it to other threads. However the script does not what I am expected it should do. My file might look like this: Line1 Line2 Line3 And my script could... (7 Replies)
Discussion started by: Timo_HR
7 Replies

10. Shell Programming and Scripting

Needed shell script to append desired text to each line in a file

Hi, I had generated a report in my tool as followsoutput.txt 43.35 9 i needed the script to generate a new file like below i want to append the text to each of these lines of my filenewoutputfile.txt should be Total Amount : 43.35 Record Count:9 Regards, Vasa Saikumar. ... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies
wanbootutil(1M) 					  System Administration Commands					   wanbootutil(1M)

NAME
wanbootutil - manage keys and certificates for WAN booting SYNOPSIS
wanbootutil [keygen] [option_specific_arguments] wanbootutil [keymgmt] [option_specific_arguments] wanbootutil [p12split] [option_specific_arguments] DESCRIPTION
The wanbootutil command creates and manages WANboot encyrption and hashing keys and manipulates PKCS #12 files for use by WAN boot. wanbootutil has three subcommands, each covered in a separate man page: wanboot_keygen(1M) Generates encryption and hashing keys. wanboot_keymgmt(1M) Inserts and extracts keys from WAN boot key repositories. wanboot_p12split(1M) Splits a PKCS #12 file into separate certificate and key files for use by WAN boot. OPTIONS
The options are supported for wanbootutil are the use of keygen, keymgmt, or p12split. The options for these subcommands are described in their respective man pages. EXAMPLES
Example 1 Generate a 3DES Client Key # wanbootutil keygen -c -o net=172.16.174.0,cid=010003BA0E6A36,type=3des Example 2 Insert an RSA Private Client Key wanbootutil keymgmt -i -k keyfile -s /etc/netboot/172.16.174.0/010003BA0E6A36/keystore -o type=rsa Example 3 Split a PKCS #12 File into Certificate and Key Components # wanbootutil p12split -i p12file -c out_cert -k out_key EXIT STATUS
0 Successful operation. non-zero An error occurred. Writes an appropriate error message to standard error. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWwbsup | +-----------------------------+-----------------------------+ |Interface Stability |Obsolete | +-----------------------------+-----------------------------+ SEE ALSO
wanboot_keygen(1M), wanboot_keymgmt(1M), wanboot_p12split(1M), attributes(5) SunOS 5.11 18 Apr 2003 wanbootutil(1M)
All times are GMT -4. The time now is 12:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy