Register
It is currently Sat Sep 20, 2014 3:58 am

simple bash text editor.


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Wed Mar 15, 2006 10:47 am   

Joined: Fri Oct 14, 2005 9:30 am
Posts: 61
This is nothing special, you are better off using kate, gedit or vim.
Download it here.
Code:
#!/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 ;
cat $filename
read -p " " text ;
echo $text >> $filename ;
clear ;
echo "the file now looks like this :"
cat $filename
sleep 3
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

I made this script purely out of curiosity of what I could do with bash.


Top
 Profile WWW  
 PostPosted: Wed Mar 15, 2006 11:33 am   

Joined: Fri Oct 14, 2005 9:30 am
Posts: 61
Ok, new version - this version supports adding new lines - instead of using enter to exit it adds a new line and ctrl + c is exit. I am proud of this effort.
Download it here.
Code:
#!/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


Top
 Profile WWW  
 PostPosted: Wed Mar 15, 2006 11:34 am   

Joined: Fri Oct 14, 2005 9:30 am
Posts: 61
yet another new version - this one has a function just to look at files - not to edit them.
Download it here.
Code:
#!/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 ()
{
[rob@localhost ~]$ 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


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP