- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Doubt on vi in non-interactive mode
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2002 06:57 AM
06-10-2002 06:57 AM
I was trying to edit a file using vi through a shell script.
#!/bin/ksh
vi - 1.txt <
i
New text
:wq
EOF
In the above script, after I do the insert, I need to return to the command mode. How do I enter the escape key in the script file to come back to the command mode?
Thanks.
Regards,
Ram.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2002 07:00 AM
06-10-2002 07:00 AM
Re: Doubt on vi in non-interactive mode
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2002 07:22 AM
06-10-2002 07:22 AM
Re: Doubt on vi in non-interactive mode
Why don't U use sed command for non interactive edition..It is very simple. I will give the syntax here
/line address/itext
eg: Suppose U have line like this
" HPUNIX is the best Unix" and U want to insert a line like this "HPUNIX is a 64 bit UX" Then script should be like this
/HPUNIX/iHPUNIX is a 64 bit ux
Best of luck
Shahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2002 07:25 AM
06-10-2002 07:25 AM
Re: Doubt on vi in non-interactive mode
I tried that, but I'm afraid it didn't work for me. I'm on HP-UX 11. Could it have something to with that?
Regards,
Ram.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2002 07:34 AM
06-10-2002 07:34 AM
Re: Doubt on vi in non-interactive mode
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2002 07:48 AM
06-10-2002 07:48 AM
Re: Doubt on vi in non-interactive mode
Thank you for your replies.
Actually, I'm not sure if I could use sed in my situation. It is like this. I'm actually running a script (which I cannot change) which needs to read in some comments half way down its processing. To read in the comments, it opens a temp file in vi. This file already has one line of text and I need to erase the contents and add my own text. I was trying to run this standard script from my own shell script (something like a batch script) which would invoke the standard script with different parameters multiple times. Would I be able to handle this using sed?
Regards,
Ram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2002 08:00 AM
06-10-2002 08:00 AM
Re: Doubt on vi in non-interactive mode
If that is the case and you just want one line in the file prior to the user who enters in the comment, then do the following in your script.
cat - <
yourtext
EOD
vi 1.txt
That way the user of your script can begin adding comments and "yourtext" will be the first line.
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2002 08:34 AM
06-10-2002 08:34 AM
Re: Doubt on vi in non-interactive mode
Thanks.
Regards,
Ram.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2002 08:37 AM
06-10-2002 08:37 AM
SolutionUSE "ed"
# cat 1.txt
this is line 1
this is line 2
this is line 3
this is line 4
# cat ttt
#!/usr/bin/ksh
ed - 1.txt <
d
.i
New text
.
w
q
EOF
# ./ttt
this is line 1
# cat 1.txt
New text
this is line 2
this is line 3
this is line 4
#
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2002 01:49 AM
06-11-2002 01:49 AM
Re: Doubt on vi in non-interactive mode
ex (line mode vi)
Would be best
Steve Steel