How do i write script using vi editor in ubuntu?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How do i write script using vi editor in ubuntu?
# 1  
Old 07-07-2009
Java How do i write script using vi editor in ubuntu?

Hi,
i still new to ubuntu
i trying to find how do i write script in ubuntu using vi editor
but i cant find a way to write it
for example
write a script to list out various script titles and short description of the scripts and allow users to choose which to run?
how i run the scripts after finish the script?
# 2  
Old 07-07-2009
vi script
:wq to save the script

most important - and you will find it on all UNIX systems

man vi
(your saver...)

to run script:
man chmod

P.S.
Did you put as first line the call of which shell to be used?
e.g.
Code:
#! /usr/bin/ksh
.
.

P.S.2

Looks like homework to me...

Last edited by vbe; 07-07-2009 at 03:05 PM.. Reason: typos and addemdum
# 3  
Old 07-07-2009
It sounds like you have many problems.

1. How to use vi
__1a. How to start vi
__1b. Using vi
__1c. Saving a file in vi
2. How to write a shell script
__2a. Shebang
__2b. Authoring
3. How to run a shell script
__3a. How to set permissions on a shell script
__3b. Executing the script

vbe addressed 1c, 2a, and 3a. 1b and 2b will require a good deal of time for you to learn (though the basics are easy). As for the others:

You can start vi from the console by typing
Code:
vi

Once you have set the permissions for a script, say example.sh, you can run it (from the same directory) with
Code:
./example.sh

# 4  
Old 07-07-2009
How do i write script using vi editor in ubuntu?

If i using the shell bash?
# 5  
Old 07-08-2009
Homework is not permitted at The UNIX and Linux Forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh script to edit a file using vi editor

I was wondering if it is possible to execute a script that will remove a certain search pattern from a file and save it? Manually I would just hit escape to enter command mode then search and delete the pattern "./srv 135.0.0.1.11111 210;=1" then save & exit the file vi command to search and... (3 Replies)
Discussion started by: seekryts15
3 Replies

2. Shell Programming and Scripting

Need to overwrite shell script using vi editor

I have an existing shell script that I am trying to modify. I have about 10 lines of info I want to overwrite using text someone emailed to me. I guess what I am trying to do basically is like a copy/paste, but it's not working for me. I am using Cygwin and vi editor. I open the script and... (4 Replies)
Discussion started by: kimberlyg2007
4 Replies

3. Shell Programming and Scripting

wrapper script design for gnu ed text editor i/o

Hi. I'm having trouble writing a wrapper script for the command line text editor gnu ed. I want to be able to run the following algorithm on ed: 1. Display, on stdout, a command which I intend to feed into ed (before I actually feed it to ed). 2. Actually feed the command into ed's stdin.... (2 Replies)
Discussion started by: vomv1988
2 Replies

4. Shell Programming and Scripting

[Solved] Help with running ps -e | less on nano script editor

p { margin-bottom: 0.08in; } This is just a portion of a script I'm writing on Linux nano script editor. When I run the script I get stuck on the ps -e | less command portion of the script:wall:. It displays all the process running but it does not allow me to move to the next line on the script.... (2 Replies)
Discussion started by: SANA4SPA
2 Replies

5. Shell Programming and Scripting

Using Ex editor commands in a shell script - Help!

Hi all, I am trying to use the Ex editor and its commands in a script - more specifically within an if statement within a while loop. Here are the basics of the loop: cat $file1 | while read line do grep $line $file2 if ] then echo $line > $file2 elseex $file2 /ESI185... (4 Replies)
Discussion started by: luke222010
4 Replies

6. UNIX for Dummies Questions & Answers

Modifying a shell script without using an editor

Hi all, I really wan't to know that how to edit a shell script with out using an editor.. Is there any command? (4 Replies)
Discussion started by: buddhi
4 Replies

7. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

8. UNIX for Dummies Questions & Answers

displaying stdout of a script using vi editor

Hi, Is there a way to display the stdout of a script using vi editor without writing the stdout to a file. I have a script (format.sh) which reads a file and displays it in a special format. i want to see this displayed text using vi editor? currently i am doing: format.sh myfile> out.txt... (1 Reply)
Discussion started by: yakari
1 Replies

9. Shell Programming and Scripting

set EDITOR=vi -> default editor not setting for cron tab

Hi All, I am running a script , working very fine on cmd prompt. The problem is that when I open do crontab -e even after setting editor to vi by set EDITOR=vi it does not open a vi editor , rather it do as below..... ///////////////////////////////////////////////////// $ set... (6 Replies)
Discussion started by: aarora_98
6 Replies

10. UNIX for Dummies Questions & Answers

Pasting text in VI editor from a different editor

Hi, I knw its a silly question, but am a newbie to 'vi' editor. I'm forced to use this, hence kindly help me with this question. How can i paste a chunk 'copied from' a different editor(gedit) in 'vi editor'? As i see, p & P options does work only within 'vi'. (10 Replies)
Discussion started by: harishmitty
10 Replies
Login or Register to Ask a Question