The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Is there a awk solution for this?? timj123 Shell Programming and Scripting 7 03-14-2008 03:28 AM
Is There a Sed Solution for This? racbern Shell Programming and Scripting 1 03-13-2008 08:31 AM
Grep solution Amruta Pitkar Shell Programming and Scripting 3 05-02-2007 11:57 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-30-2008
kkc kkc is offline
Registered User
 

Join Date: Oct 2007
Posts: 12
need solution for scripting

hi all,

i would like to add on the print command to prompt user to enter a value and store inside the variable name as $inName
after that the value will replace the existing line for ${METRICA_DIR}/TechnologyPacks/Spool/2030324032
i'm new in scripting, could anyone give me some hint for sripting?

tmpfile=/tmp/tmpfile.$$

for file in loaderconfiguration*.xml
do
sed 's|${METRICA_DIR}/TechnologyPacks/Spool/2030324032|$inName|g' $file > $tmpfile
mv $tmpfile $file
done

thanks
Reply With Quote
Forum Sponsor
  #2  
Old 01-30-2008
nivas
Guest
 

Posts: n/a
Shell Programming

Hi,

Iam new to Shell programming and i want to Display the same lines in a file which is appearing more than once.

Here is a file format,

WERTFRT|1234567890
ASDFFGU|1230986545
WERTFRT|1234567890
CVBNMKL|7685645385

Here 1st and 3rd lines are same and i need to select and write it in to seperate file.
please help me.

Thanks in advance.
Reply With Quote
  #3  
Old 01-30-2008
Registered User
 

Join Date: Jun 2007
Location: Beijing China
Posts: 495
double quote

hi KKC,

please you double quote <"> instead of single quote <'> in your sed command, then it should be ok.
Reply With Quote
  #4  
Old 01-30-2008
kkc kkc is offline
Registered User
 

Join Date: Oct 2007
Posts: 12
Quote:
Originally Posted by summer_cherry View Post
hi KKC,

please you double quote <"> instead of single quote <'> in your sed command, then it should be ok.
sorry i can't get you mean,
i wanted add on such like

print "what is your directory : ";
then the answer is storing to &inName

and the sed will replace the &inName to ${METRICA_DIR}/TechnologyPacks/Spool/2030324032

sed 's|${METRICA_DIR}/TechnologyPacks/Spool/2030324032|$inName|g' $file

Thanks in advance
Reply With Quote
  #5  
Old 01-30-2008
Registered User
 

Join Date: Jan 2007
Location: Boston, USA
Posts: 16
Thumbs up Clarification....

Hi KKC,

summer_cherry was asking you to replace the single codes in the sed command with double codes.

Code:
sed "s|${METRICA_DIR}/TechnologyPacks/Spool/2030324032|$inName|g" $file
==========
Thanks,
Karthikeyan.
==========
Reply With Quote
  #6  
Old 01-30-2008
kkc kkc is offline
Registered User
 

Join Date: Oct 2007
Posts: 12
Quote:
Originally Posted by Karthikeyan_113 View Post
Hi KKC,

summer_cherry was asking you to replace the single codes in the sed command with double codes.

Code:
sed "s|${METRICA_DIR}/TechnologyPacks/Spool/2030324032|$inName|g" $file
==========
Thanks,
Karthikeyan.
==========
hi

thanks for the advise~, what is the different withe replace the single codes in the sed command with double codes?

many thanks
Reply With Quote
  #7  
Old 01-30-2008
Registered User
 

Join Date: Aug 2007
Location: Bangalore
Posts: 288
You can do something like this--

echo "Enter the file/dir name"
read file

then do the replacements here-
sed "s|${METRICA_DIR}/TechnologyPacks/Spool/2030324032|$inName|g" $file

Thanks
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0