LDP/LDP/guide/docbook/abs-guide/ex69.sh

34 lines
652 B
Bash
Raw Normal View History

2001-07-10 14:25:50 +00:00
#!/bin/bash
2008-11-23 22:43:47 +00:00
# Noninteractive use of 'vi' to edit a file.
2001-07-10 14:25:50 +00:00
# Emulates 'sed'.
2008-11-23 22:43:47 +00:00
E_BADARGS=85
2001-07-10 14:25:50 +00:00
if [ -z "$1" ]
then
echo "Usage: `basename $0` filename"
exit $E_BADARGS
fi
TARGETFILE=$1
2001-09-04 13:27:31 +00:00
# Insert 2 lines in file, then save.
#--------Begin here document-----------#
2001-07-10 14:25:50 +00:00
vi $TARGETFILE <<x23LimitStringx23
i
This is line 1 of the example file.
This is line 2 of the example file.
^[
ZZ
x23LimitStringx23
2001-09-04 13:27:31 +00:00
#----------End here document-----------#
2001-07-10 14:25:50 +00:00
2002-04-01 16:04:17 +00:00
# Note that ^[ above is a literal escape
#+ typed by Control-V <Esc>.
2008-11-23 22:43:47 +00:00
# Bram Moolenaar points out that this may not work with 'vim'
2002-04-01 16:04:17 +00:00
#+ because of possible problems with terminal interaction.
2001-07-10 14:25:50 +00:00
2008-11-23 22:43:47 +00:00
exit