yet another new version - this one has a function just to look at files - not to edit them.
#!/bin/bash
function -noedit ()
{
read -p "What file would you like to look at ? " filename
cat $filename | more
exit
}
function script ()
{
clear
echo "Run $0 -noedit to just look at a file"
echo "run $0 -overwrite to overwrite a file"
echo "Run $0 -edit to edit a existing file "
echo " Commands: Press enter to save file ;when done press ctrl + c to exit ."
read -p " Press enter to start typing " enter
clear
newline
clear
exit
}
function newline ()
{
read -p " " text
echo $text >> $filename
clear
cat $filename
newline
}
function -overwrite ()
{
[
[email protected] ~]$ cat bashedit
#!/bin/bash
function -edit ()
{
clear ;
read -p "What is the name of the file you would like to edit : " filename
clear
read -p " Commands: Press enter to save file when done. Press enter now to start typing." enter ;
clear ;
read -p " " text ;
echo $text >> $filename ;
clear ;
exit
}
function filexist ()
{
if [[ -e $filename ]]
then
echo "file already exists, please choose another name. If you would like to edit " ;
read -p "this file, run $0 -edit . Please enter new filename : " filename ;
filexist ;
fi
}
$1
read -p "What would you like to call the file ? " filename
filexist
touch $filename
clear
read -p " Commands: Press enter to save file when done. Press enter now to start typing." enter
clear
read -p " " text
echo $text >> $filename
clear
exit