Add name at the end of line in one file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Add name at the end of line in one file
# 8  
Old 05-09-2012
try this

Code:
 
awk -F: -v inp="$masterlogin" 'tolower($0)~tolower(inp) {print $0":newserver"}1' passwd.master

# 9  
Old 05-09-2012
its crreating new line above the susan while running the script..but its not reflecting inside the file after execution...

Code:
masterlogin: susan
susan:x:6852:999:sudhar:aweurutrt:etyte:ratet
Value of Search_masterlogin :susan
master user account found
Enter the host name in useraddhost newhost

susan:x:6852:999:sudhar:aweurutrt:etyte:ratet :newhost 
susan:x:6852:999:sudhar:aweurutrt:etyte:ratet


$ grep susan passwd.master
susan:x:6852:999:sudhar:aweurutrt:etyte:ratet
$


Last edited by susindram; 05-09-2012 at 04:39 AM.. Reason: edited some mistake
# 10  
Old 05-09-2012
Code:
awk -F: -v inp="$masterlogin" 'tolower($0)~tolower(inp) {$0=$0":newserver"}1' passwd.master > newfile.txt

check the newfile.txt
# 11  
Old 05-09-2012
perfect kamaraj....Thanks for your help...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add new line at beginning and end of a file

Hi, I have a specific requirement to add text at the beginning and end of a plain text file. I tried to use "sed" with '1i' and '$a' flags but these required two separate "sed" commands separated with "|". I am looking for some command/option to join these two in single command parameter. ... (6 Replies)
Discussion started by: bhupinder08
6 Replies

2. UNIX for Dummies Questions & Answers

Add blank line to end of file

Alright, so I was looking around a bit on the forum before posting and still don't really understand so I figured I'd post my own question. I am appending two files using cat file_1.txt >> file_2.txt The problem is that I need a blank line in between the two different text files and it does... (2 Replies)
Discussion started by: cgagnon
2 Replies

3. UNIX for Dummies Questions & Answers

Merge files and add file name to the end of each line

Hello everybody, I'm trying to merge a lot of files, but I want to include the filename to the end of each line. I've tried to use cat, but I got stuck. My files are for example: file01.001 123456 aaa ddd ee 458741 eee fff ee file02.003 478596 uuu ddd ee 145269 ttt fff ee ... (4 Replies)
Discussion started by: ernesto561
4 Replies

4. Shell Programming and Scripting

add character to every end-of line in file

Hi All I have a file which conatins record.the length of every records is 47. problem : in the end of record i don't have a "\015" character. i want to add this "\015" charcter in the end of every record. the file contains something like 700 records. i've tried with sed command - nothing. ... (8 Replies)
Discussion started by: naamas03
8 Replies

5. Shell Programming and Scripting

add character to the end of each line in file

hi all i have 32 lines in file. the length of each line is 82 , i want that in the end of each line , means in postion 83-84 to put two characters 0d(=\015), 0a(=\012) i want that the 0d will be in postion 83 and the 0a will be in postion 84 in each line of the file how shall i do it ? ... (7 Replies)
Discussion started by: naamas03
7 Replies

6. Shell Programming and Scripting

add a line at the end of a file using shell scripting

Hi All , I am new to shell scripting. i have a shell script(which is executed as a super user) , i want to it to do one more job for me. ie mounting a directory over other using lofs . i have done it manually using 1) using mount command mount -F lofs /export/home/dju /dju 2)... (4 Replies)
Discussion started by: meet123321
4 Replies

7. UNIX for Dummies Questions & Answers

How to add new line character at the end of a file

hi all, i have this question: How to add new line character at the end of a file???? i need this because i am loading a file to sybase and i have problems with the last record thanks for your help (5 Replies)
Discussion started by: DebianJ
5 Replies

8. Shell Programming and Scripting

Add a word at the end of each line in a file

Hi I want to read a flat file and add a word/value at the end of each line in the file and store the output in a temporary file. How can i do this? Plz help me with this. Regards, Saurabh (6 Replies)
Discussion started by: bhalotias
6 Replies

9. Shell Programming and Scripting

How to add filename to the end of each line in file

Hi, I'm reading data from comma separated files to DB. Now there is a need to have the name of the input file in each row of that file. How can I do this in unix script? Example: $cat file1 value11,value12, value,13 value21,value22, value,23 value31,value32, value,33 And the result... (2 Replies)
Discussion started by: tmikahan
2 Replies

10. UNIX for Dummies Questions & Answers

add data from command line to end of file

how can I add data from command line to end of file? (3 Replies)
Discussion started by: bryan
3 Replies
Login or Register to Ask a Question