Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users


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.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-20-2012
Registered User
 
Join Date: Jan 2012
Posts: 26
Thanks: 13
Thanked 1 Time in 1 Post
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
Mead Rotor
 
Join Date: Aug 2005
Location: Saskatchewan
Posts: 16,374
Thanks: 491
Thanked 2,535 Times in 2,418 Posts
And what output do you want from that?
Sponsored Links
    #3  
Old 06-25-2012
Registered User
 
Join Date: Jan 2012
Posts: 26
Thanks: 13
Thanked 1 Time in 1 Post
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
Mead Rotor
 
Join Date: Aug 2005
Location: Saskatchewan
Posts: 16,374
Thanks: 491
Thanked 2,535 Times in 2,418 Posts
Yes, but what output do you want? Show it, don't just describe it.
Sponsored Links
    #5  
Old 06-25-2012
Registered User
 
Join Date: Jan 2012
Posts: 26
Thanks: 13
Thanked 1 Time in 1 Post
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
Mead Rotor
 
Join Date: Aug 2005
Location: Saskatchewan
Posts: 16,374
Thanks: 491
Thanked 2,535 Times in 2,418 Posts

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
Registered User
 
Join Date: Jan 2012
Posts: 26
Thanks: 13
Thanked 1 Time in 1 Post
Thank you..Code worked..

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

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:42 AM.