sed to append on specific line in password file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed to append on specific line in password file
# 1  
Old 06-25-2012
sed to append on specific line in password file

I have the a group file and my ftp group line looks like this


Code:
ftp::49:cccmi,tngs,sloans,wlppdo,tsynergy,tuhcelpaso,tfuddruck,twlpmidwest,tocrproj,tbapco,tbdeuro,tclaimshop,tscselpaso,teldrpln,tpinnacle,tbdiap,tpacdent,tuhcmamsi,tinficr,tagia,tmwest,tppom2,tuhcfclm,tdatafax,tpcareclm,tbrinker,twlpdenscn,thdrtv,tmhead,tcqgpi,twlpmocha4,tsiapwf,tnbsrcm,tscsdbp,tcdwinv,tdiesel,tmayap,tbscclm,thdrsw,tavayaexp,tgegbsinv,tbrinkerte,tbrinkerpay,tuhcbefm,tbtob,tuhc,thdinv,tdbrands,ttwteleap,tpmswf,tmbusaap,tconveyw9,tkrogereaa,tuhcclm,tidg,tahold,uhcchk21,tlifecon,dcambap,tconfin,tiffap,tusc,tsfcc,tuhgingen,tstnhou,tuhgc,thps,twlpwest,tuhge,tibm,tphp,tbcbsnc,tmponenet,tdquick,tbdapac,tdirectv,tuhgag,tadds,tuhgpri,tcartus,taisi,twlppdo,trevmed,thmspay,tngspark,tfleetpr,tprg,tfordhri9,tcpkhrit,triver,thmsproj,thomeserve,tnyspit

I want to append a username using sed to the end of the line including the "," comma

Last edited by Scrutinizer; 06-25-2012 at 06:24 PM.. Reason: code tags
# 2  
Old 06-25-2012
See usermod, if that is used on your system. If not what is your OS and version?
# 3  
Old 06-25-2012
usermod doesn't wor

I can 't use usermod because I can't update the software for it
# 4  
Old 06-26-2012
try this:
Code:
sed '/ftp/ s/$/,username/' outputfile

if everything is working you can run:
Code:
sed -i '/ftp/ s/$/,username/' outputfile

p.s. I assumed you do not have groups ftp and ftp1, ftp2 ..etc
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed to replace specific positions on line with file contents

Hi, I am trying to use an awk command to replace specific character positions on a line beginning with 80 with contents of another file. The line beginning with 80 in file1 is as follows: I want to replace the 000000000178800 (positions 34 - 49) on this file with the contents of... (2 Replies)
Discussion started by: nwalsh88
2 Replies

2. UNIX for Dummies Questions & Answers

using sed delete a line from csv file based on specific data in two separate fields

Hello, :wall: I have a 12 column csv file. I wish to delete the entire line if column 7 = hello and column 12 = goodbye. I have tried everything that I can find in all of my ref books. I know this does not work /^*,*,*,*,*,*,"hello",*,*,*,*,"goodbye"/d Any ideas? Thanks Please... (2 Replies)
Discussion started by: Chris Eagleson
2 Replies

3. 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

4. Shell Programming and Scripting

Passing parameter in sed or awk commands to print for the specific line in a file

Hi, I am trying to print a specific line in a file through sed or awk. The line number will be passed as a parameter from the previous step. My code looks as below. TEMP3=`sed -n '$TEMP2p' $FILEPATH/Log.txt` $TEMP2, I am getting from the previous step which is a numerical value(eg:3). ... (2 Replies)
Discussion started by: satyasrin82
2 Replies

5. Shell Programming and Scripting

Replace specific field on specific line sed or awk

I'm trying to update a text file via sed/awk, after a lot of searching I still can't find a code snippet that I can get to work. Brief overview: I have user input a line to a variable, I then find a specific value in this line 10th field in this case. After asking for new input and doing some... (14 Replies)
Discussion started by: crownedzero
14 Replies

6. Shell Programming and Scripting

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... (5 Replies)
Discussion started by: momin
5 Replies

7. Shell Programming and Scripting

How to append a character to the last but one field on a specific line?

Hi Guys, I have a file like this: aaa b c d e f fsss g h i k l qqq r t h n I want: aaa b c d e f fsss g h i k l qqq r t h , n ggg p t e d u qqq i o s , k (2 Replies)
Discussion started by: npatwardhan
2 Replies

8. Shell Programming and Scripting

How to append a string to a specific location in a line

Hi, I have a to modify a line and insert a keyword in the middle to a specific location. My line looks like this FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS (ABC, DEF, GHI) I want to change it as FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"' TRAILING... (4 Replies)
Discussion started by: mwrg
4 Replies

9. Shell Programming and Scripting

using sed to replace a specific string on a specific line number using variables

using sed to replace a specific string on a specific line number using variables this is where i am at grep -v WARNING output | grep -v spawn | grep -v Passphrase | grep -v Authentication | grep -v '/sbin/tfadmin netguard -C'| grep -v 'NETWORK>' >> output.clean grep -n Destination... (2 Replies)
Discussion started by: todd.cutting
2 Replies

10. Shell Programming and Scripting

sed append "\n" to end of every line in file

I know it sounds simple, but I want to e-mail the last 6 lines of a log file, which I have tailed into logresults.txt. I'm using echo -e "Subject:server results\nFrom:server log <user@domain.com>\n"`cat logresults.txt` | sendmail -t user@domain.com which works, but the body of the e-mail has... (4 Replies)
Discussion started by: unclecameron
4 Replies
Login or Register to Ask a Question