Unix/Linux Go Back    


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

UNIX for Advanced & Expert Users


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 06-20-2012   -   Original Discussion by chandu123
chandu123 chandu123 is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 3 July 2014, 2:46 PM EDT
Posts: 31
Thanks: 18
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 05:26 PM.. Reason: code tags
Sponsored Links
    #2  
Old Unix and Linux 06-20-2012   -   Original Discussion by chandu123
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 21 November 2017, 3:22 PM EST
Location: Saskatchewan
Posts: 22,518
Thanks: 1,154
Thanked 4,273 Times in 3,946 Posts
And what output do you want from that?
Sponsored Links
    #3  
Old Unix and Linux 06-25-2012   -   Original Discussion by chandu123
chandu123 chandu123 is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 3 July 2014, 2:46 PM EDT
Posts: 31
Thanks: 18
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 Unix and Linux 06-25-2012   -   Original Discussion by chandu123
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 21 November 2017, 3:22 PM EST
Location: Saskatchewan
Posts: 22,518
Thanks: 1,154
Thanked 4,273 Times in 3,946 Posts
Yes, but what output do you want? Show it, don't just describe it.
Sponsored Links
    #5  
Old Unix and Linux 06-25-2012   -   Original Discussion by chandu123
chandu123 chandu123 is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 3 July 2014, 2:46 PM EDT
Posts: 31
Thanks: 18
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 05:27 PM..
Sponsored Links
    #6  
Old Unix and Linux 06-26-2012   -   Original Discussion by chandu123
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 21 November 2017, 3:22 PM EST
Location: Saskatchewan
Posts: 22,518
Thanks: 1,154
Thanked 4,273 Times in 3,946 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 Unix and Linux 06-26-2012   -   Original Discussion by chandu123
chandu123 chandu123 is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 3 July 2014, 2:46 PM EDT
Posts: 31
Thanks: 18
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 Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 11:35 AM
How to replace double quotes in to ascii value? rajesh4851 UNIX for Dummies Questions & Answers 4 05-11-2011 04:27 AM
sed replace spaces between quotes with a variable EXT3FSCK Shell Programming and Scripting 3 03-07-2010 01:22 AM
replace value with double quotes of specific coulmn value in csv file techmoris Shell Programming and Scripting 3 08-03-2009 10:37 PM
Replace multiple blanks within double quotes jgrogan Shell Programming and Scripting 5 07-14-2008 10:54 AM



All times are GMT -4. The time now is 05:20 AM.