UNIX for Advanced & Expert Users

Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

Replace a value in the file that start with quotes

👤 Login to reply

    #1  
Old 06-20-2012
chandu123 chandu123 is offline
Registered User
 
Replace a value in the file that start with quotes

I have to replace the specific encypted [LL9@99V@N=3M0O4I4;J43KH6] value in the file which is will be a taken as input from user always.PADWD appears two times in the document of which I need to replace the line which start with double quotes. Please help.

Code:
"PADWD"\1\"LL9@99V@N=3M0O4I4;J43KH6"---Sample line in the file.

Thanks
Chand

Last edited by Scrutinizer; 06-25-2012 at 04:26 PM.. Reason: code tags
Sponsored Links
    #2  
Old 06-20-2012
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
And what output do you want from that?
Sponsored Links
    #3  
Old 06-25-2012
chandu123 chandu123 is offline
Registered User
 
Once the value is inserted i will be running a related job for which I have tested command and is running fine. Please help me with insert code. Thank you.
    #4  
Old 06-25-2012
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Yes, but what output do you want? Show it, don't just describe it.
Sponsored Links
    #5  
Old 06-25-2012
chandu123 chandu123 is offline
Registered User
 
Old value in the file --->
Code:
"PADWD"\1\"LL9@99V@N=3M0O4I4;J43KH6"

New encrypted value taken as input -
Code:
LL9@99V@N=34566666

Expected output-
Code:
"PADWD"\1\"LL9@99V@N=34566666"

. Please help.

Last edited by Scrutinizer; 06-25-2012 at 04:27 PM..
Sponsored Links
    #6  
Old 06-26-2012
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Code:
VAR="LL9@99V@N=34566666"
OLDIFS="$IFS"; IFS="="
set -- $VAR
IFS="$OLDIFS"

awk '/"PADWD"/ && ($0 ~ P1) { sub(/"[^="]*=[^"]*"$/, "\"" P1 "=" P2 "\""); } 1' P1=$1 P2=$2 inputfile > outputfile

The Following User Says Thank You to Corona688 For This Useful Post:
chandu123 (06-26-2012)
Sponsored Links
    #7  
Old 06-26-2012
chandu123 chandu123 is offline
Registered User
 
Thank you..Code worked..

-Chandra..
The Following User Says Thank You to chandu123 For This Useful Post:
Corona688 (06-26-2012)
Sponsored Links
👤 Login to reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Search replace strings between single quotes in a text file Hiano Shell Programming and Scripting 7 07-15-2011 10:35 AM
How to replace double quotes in to ascii value? rajesh4851 UNIX for Dummies Questions & Answers 4 05-11-2011 03:27 AM
sed replace spaces between quotes with a variable EXT3FSCK Shell Programming and Scripting 3 03-07-2010 12:22 AM
replace value with double quotes of specific coulmn value in csv file techmoris Shell Programming and Scripting 3 08-03-2009 09:37 PM
Replace multiple blanks within double quotes jgrogan Shell Programming and Scripting 5 07-14-2008 09:54 AM



All times are GMT -4. The time now is 01:46 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
×
UNIX.COM Login
Username:
Password:  
Show Password





Not a Forum Member?
Forgot Password?