The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > AIX
Google UNIX.COM


AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Local shell script need to be executed on a remote linux box rajeshomallur Linux 6 05-02-2008 10:05 AM
perl - why is the shell script executed before the print command? mjays Shell Programming and Scripting 3 09-21-2007 02:49 AM
Unix shell script couldn't be executed. Pls help! duke0001 Shell Programming and Scripting 8 09-14-2006 08:15 PM
Shell script doesn't get executed using crontab radhika Shell Programming and Scripting 11 06-09-2005 01:28 PM
simple shell - how to get a parameter typed in a shell script cmitulescu Shell Programming and Scripting 3 12-05-2001 12:04 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-03-2006
Registered User
 

Join Date: Jun 2006
Posts: 2
Help - Need simple example of VI executed in shell script

Please help - I have seen others ask this question but I need a simple example of using vi in a shell script. Once I enter VI the shell script does not execute the next commands until I q!. I invoke VI and start the edit process. I want to go to the third line and replace a character with a new character and then :wq. There must be a special character set required to feed the script. Not sure how to get <esc> intol script, if I need it at all. A simple example would be great. Please type and reply. Thanks
Reply With Quote
Forum Sponsor
  #2  
Old 06-03-2006
Registered User
 

Join Date: Feb 2006
Location: Schenectady, NY
Posts: 130
Traditionally, vi is an interactive editor. I am hardpressed to imagine a situation where its functionality can not be replaced by sed -- the stream editor -- or a pipeline series of grep, awk, etc... I'd advise avoiding the vi solution though I'm sure it is possible.

Can you be more specific with your data? For example, are you always replacing a character on the third line only or is there a specific pattern that uniquely identifies that line?

Here is a simple example that replaces all lowercase 'e' characters with an uppercase 'E' on line 3 only. Given the following file:

Code:
$ cat file
line 1 one
line 2 two
line 3 three
line 4 four
$ cat file | sed -e "3s/e/E/g"
line 1 one
line 2 two
linE 3 thrEE
line 4 four
You could then redirect the output to a temporary file, say file.tmp and then move it back to file.

Code:
$ cat file | sed -e "3s/e/E/g" 1>file.tmp && mv file.tmp file

Last edited by hegemaro; 06-03-2006 at 09:49 AM.
Reply With Quote
  #3  
Old 06-03-2006
Registered User
 

Join Date: Jun 2006
Posts: 2
Thanks for the SED command - will work well

Thanks for the SED. This should work well and achieve my goal.
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 05:56 PM.


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