vi is basically used independently .....but what if vi commands are used in shell script ?
I am trying to accomplish functionality of mv command using a shell script.
what I want is to yank whole text of one file1 and paste it in file2.
this all should happen in Shell Script.
So far I have dont following script.
#!/bin/bash
#file.sh
echo -e "\n\t|------------------ File Transfer -----------------------|"
while [ "$ch" != "n" ]
do
echo -e "\nEnter directory"
read dir
echo -e "\nEnter filename"
read flnam
if [ -d $dir ]
then
if [ -e $flnm ]
then
vi $flnm `| "+y | esc | :x` # ERROR
cd $dir
vi $flnm `| p | esc | :x` # ERROR
fi
else
echo "Directory does not exists."
fi
echo "Do you want to try again? (y/n)"
read ch
done
vi commands are not working in shell script.....I know am missing right format of its use.
Any Suggestions ?