Opening a file in vi and automatically save and quit this file using shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Opening a file in vi and automatically save and quit this file using shell script
# 1  
Old 11-25-2013
Question Opening a file in vi and automatically save and quit this file using shell script

Hi friends,
In my shell script, I want to open a file using vi editor. After opening the file in vi, I want to save and quit this file automatically.... all through shell script.

the code segment is:
------------------------------------------------------------
Code:
cd ~/netfpga/projects/scone/sw/
sudo vi cpuhw

-------------------------------------------------------------

Can anyone please help me.
Thanks in anticipation

Last edited by Don Cragun; 11-25-2013 at 03:48 PM.. Reason: Please use CODE tags.
# 2  
Old 11-25-2013
This sounds strange. vi is an interactive tool - how should the shellscript know that the actions done in vi are finished?
What is your final goal? Are you trying to modify a file? There are text processors like sed or awk that are designed for that.
# 3  
Old 11-25-2013
Quote:
Opening a file in vi and automatically save and quit this file using shell script
Hi friends,
In my shell script, I want to open a file using vi editor. After opening the file in vi, I want to save and quit this file automatically.... all through shell script.

the code segment is:
------------------------------------------------------------
cd ~/netfpga/projects/scone/sw/
sudo vi cpuhw
-------------------------------------------------------------

Can anyone please help me.
Thanks in anticipation
Hello,

Could you please let us know that which kind of change you want to make to the file (expected input and expected output will be good for us to help).

Also it's a kind request please put all commands and their output to codes.
As per rules for this forum.



Thanks,
R. Singh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Inserting shell script input data automatically from a text file

Dear experts, I am new to linux programming. I have a shell script which i should run it on all my samples. I only define input and out put for this script. The inputs are 3 numbers(coordination numbers) which are available in a series of text file. Since i have a lots of samples, it takes a... (5 Replies)
Discussion started by: mohamadreza
5 Replies

2. OS X (Apple)

Quit a shell script thats running on a remote machine

I'm in a situation where I am executing a shell script(Bash) on another machine remotely using ssh, and for various reasons sometimes need to quit it and restart it. The shell script being run does many different things, so its hard to know what process to kill on the remote machine, and even if I... (2 Replies)
Discussion started by: TheDrizzle
2 Replies

3. Shell Programming and Scripting

Save output to file - inside a script ?

I'm using the following script to check cisco router health and I'd like to save output to a file, vty_runcmd.sh > /check/check-cisco-health script works and output is saved to a file. However using it in crontab file is created but output is not printed inside it. In crontab, */5 * * * *... (4 Replies)
Discussion started by: marmellata
4 Replies

4. Shell Programming and Scripting

open file and save as script

hi guys i have a problem with my file did not work as usual. The problem is i need to open the file and save as using same name and after that the file is work properly. Is it any shell script can do open the file and save as using same name..because i have thousand of file with the same problem (3 Replies)
Discussion started by: zulabc
3 Replies

5. Shell Programming and Scripting

script file which will automatically create accounts

How tocreate a script file which will automatically create accounts from a csv file (2 Replies)
Discussion started by: donegal92
2 Replies

6. Shell Programming and Scripting

Help with opening another file from within a shell script

Hi, I am trying to open a file that I have created from withn a shell script and cannot seem to get it working. Does anyone have any ideas? Thanks. (2 Replies)
Discussion started by: tdsrogers
2 Replies

7. UNIX Desktop Questions & Answers

script to save file

Hello evry1, Trying to come up with a script that picks content from another file, and saved the new file with the original file name but adding the time when the script is run to the new file name. after which it compresses this new file. Thanks in advance (1 Reply)
Discussion started by: Targ
1 Replies

8. UNIX for Dummies Questions & Answers

Vi, write something then try to save & quit.

If I'm in Vi, write something then try to save & quit. :wq I get: "myvifile" "myvifile" E212: Can't open file for writing Press ENTER or type command to continue It won't let me save... Is it because other users on the network have access to the file also? Or I don't have permission to save? Thanks... (5 Replies)
Discussion started by: JudoMan
5 Replies

9. Shell Programming and Scripting

Opening a File with a script

Hi, i am writing a script for exporting tables in oracle, my requirement is to take parameters from the user in a file.. i have to open vi the file,, once user is done with entering the parameters i have to save the file and execite the command exp parfile=exp_2.par .. please let me... (1 Reply)
Discussion started by: saharookiedba
1 Replies

10. Shell Programming and Scripting

Urgent help required in deleting a line without opening a file usinga shell script

Hi, I need a help in deleting a line matching a particular pattern in a file using shell script without opening the file. The file is a .c/.cpp file. Is it possible? Thanks (6 Replies)
Discussion started by: naan
6 Replies
Login or Register to Ask a Question