Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How change particular word by another in this file ? 2

Status
Not open for further replies.

gargamel100

Technical User
Oct 25, 2006
31
CZ
Hi all,

I have the following file output

(2, 1, 'rambo', 'ffsffsdfsdfsd1daf15edf96ec03a4e977a12aa', 1131101341, .....

(3, 1, 'rambo1', '9fsdchyth4354547f4a1787aad393142', 1149053489, 0, ........

This is output of forum mysql database. .... means that there is some additional fields but they are not important at this moment. Is there any way to words rambo and rambo1 transfrer into rambo@ca and rambo1@ca and get output like bellow.

(2, 1, 'rambo@ca', 'ffsffsdfsdfsd1daf15edf96ec03a4e977a12aa', 1131101341, .....

(3, 1, 'rambo1@ca', '9fsdchyth4354547f4a1787aad393142', 1149053489, 0, .......

This is not clear to me how do this using awk or sed, so is there anybody out there who know just a hint how solve this problem that will be very useful for me.

Thanks in advance

 
Something like this ?
Code:
sed "s!'!@ca'!2" /path/to/input > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi when I try this

sed "s!'!@ca'!2" input_file > output_file
I got output like

bash: !'!@ca'!2": event not found

:(

 
I see, bash ...
Perhaps this ?
sed "s/'/\@ca'/2" input_file > output_file

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
This works ok, perfectly man, you are master
but is there possibility to jump over first 76th lines and apply this rule by 77th line to end. I mean first 76 lines are databases patameters like
`user_id` mediumint(8) NOT NULL default '0',
`user_active` tinyint(1) default '1',
`username` varchar(25) NOT NULL default '',
`user_password` varchar(32) NOT NULL default '',

and this solution puts @ca after 0 it change it to 0@ca and 1 it change it 1@ca, but I wish if it is possible leave this lines untouched ( I mean firs 76 lines ) and just apply your solutions on lines after 77th line.

Thank you for this help

Regards
 
I did it like this
sed "76,115 s/'/\@ca'/2" input_file > output_file

If you have some more elegant solution please write it down.

Thanks for help,
Regards
 
apply this rule by 77th line to end
sed "77,\$ s/'/\@ca'/2" input_file > output_file

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
pity that so powerful option is not documented in many sed manuals
For me it's documented in all my man sed pages.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top