The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
saving values from awk expression into shell array npatwardhan Shell Programming and Scripting 4 01-07-2009 08:58 PM
dynamic editing using shell script habzone2007 Shell Programming and Scripting 1 05-14-2008 11:55 PM
editing a file via a shell script ?? jimmyc Shell Programming and Scripting 2 03-28-2008 12:21 PM
Editing a file in a shell script jowpup UNIX for Dummies Questions & Answers 3 02-08-2005 04:45 AM
Saving Perl scrpits in a UNIX Shell hagrid UNIX for Dummies Questions & Answers 3 06-21-2001 01:42 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-23-2009
kenkanya kenkanya is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 18
Editing & Saving using shell script

Hi,
OS: Unix, linux, hp-unix (all unix flavours)

Iam trying to change some string values, special characters or otherwise in a file. As of now, i go using vi <filename>, open the file and do the edit manually and save it.
Is it possible to write a shell script so that i just run the script which inturn opens this particular file and changes all the stuff needed and save the same.
The string values will be in any line in the file.

In file change.sh (I have to change three things as mentioned below)

** change database ****

From

Code:
connect to F750PAX

To

Code:
connect to F750PBX

*** Change of path ***

From

Code:
../jre/lpp/java/J1.4.2/bin/java com.telex.pt.environment.agent.Agent $1

To

Code:
/usr/lpp/java/IBM/J1.4.2/bin/java com.telex.pt.environment.agent.Agent $1

** Change of site name and port number ****

From

Code:
hubURL=http://clist.check.com:80/PSEMHUB/hub

To

Code:
hubURL=http://register.lagoon.com:8001/PSEMHUB/hub

I suppose its possible, but iam looking for some lead from you folks. Also i would like to replicate this in windows environment by writing bat scripts (It does the same job as in unix - by changing values in saving file). In windows there is some testing tool which can be used. But iam only looking into through bat scripts and not using any tools.

Anyway this forum is apart from windows. (Can anyone give me the windows bat script blog/forum link?).

So i would appreciate if anyone case get me on the unix enivronment.

thanks for your time.

Last edited by Yogesh Sawant; 03-25-2009 at 02:31 AM.. Reason: added code tags
  #2 (permalink)  
Old 03-23-2009
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,411
Try...
Code:
perl -pi -e '
s|connect to F750PAX|connect to F750PBX|g;
s|../jre/lpp/java/J1.4.2/bin/java com.telex.pt.environment.agent.Agent $1|/usr/lpp/java/IBM/J1.4.2/bin/java com.telex.pt.environment.agent.Agent $1|g;
s|hubURL=http://clist.check.com:80/PSEMHUB/hub|hubURL=http://register.lagoon.com:8001/PSEMHUB/hub|g' filename

  #3 (permalink)  
Old 03-24-2009
kenkanya kenkanya is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 18
Oh. Thanks. Its as simple as that, which i dont know.
BTW, i understand you have used perl. I dont think i have perl installed in my box. How do i check if perl is installed?
Iam yet to know 'perl'.
Can i put this (your code) into my shell script and run the same?

thanks once again for your response.
  #4 (permalink)  
Old 03-24-2009
kenkanya kenkanya is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 18
Thanks.
I found out from another thread "how to check that perl is installed on the system". That's perl -v
and checking my box, i do see perl is installed.
  #5 (permalink)  
Old 03-24-2009
kenkanya kenkanya is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 18
Thanks once again. I put it in a shell script and its working perfectly.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:55 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0