Results 1 to 8 of 8
i wrote this script, and everytime i run the script the code deletes and i want to know why
EDIT: i also chmod 755 if anyone wanted to know
Code:
...
- 04-21-2007 #1Just Joined!
- Join Date
- Apr 2007
- Posts
- 6
learning shell scripting
i wrote this script, and everytime i run the script the code deletes and i want to know why
EDIT: i also chmod 755 if anyone wanted to know
just so everyone knows i just started to learn shell scriptingCode:$ cat > ispostive #!bin/sh # # Script to see whether argument is postive # if test $1 -gt 0 then echo "$1 number is postive" fi
- 04-22-2007 #2Linux User
- Join Date
- Aug 2006
- Posts
- 458
the code deletes? u mean it did not get saved as file "ispositive"? how did you end you session affter you typed in those lines? using cat, to end the script you should type ctrl-d. a suggestion is to use an editor like vi or emacs etc to create your script.
- 04-22-2007 #3Just Joined!
- Join Date
- Apr 2007
- Posts
- 6
umm i dont know those editer's i was useing gedit.. i guess i should learn how to use vi i guess?
Originally Posted by ghostdog74
- 04-22-2007 #4Linux User
- Join Date
- Aug 2006
- Posts
- 458
no its fine. use gedit, type in your script , save it as "ispositive" (or other names) , chmod it if necessary and you can then run the script with an argument. it should be fine.
Originally Posted by milonix
- 04-22-2007 #5forum.guy
- Join Date
- May 2004
- Location
- arch linux
- Posts
- 18,097
If you should decide that you do want to learn vim, just run the vimtutor command for a quick lesson.
Originally Posted by milonix oz
→ new members/users: read this first | new member faq
→ no private messages requesting computer support - post them on the forums!
→ please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.
- 04-22-2007 #6Just Joined!
- Join Date
- Apr 2007
- Posts
- 6
i was following Linux Shell Scripting Tutorial (LSST) v1.05r3 and he use's $ cat > filename.. at the top of code so i thought i had to put that but it look's like thats just a command to start the file am i wrong?
- 04-22-2007 #7Linux User
- Join Date
- Aug 2006
- Posts
- 458
when you do : cat > filename on the shell, cat takes in standard input from the command line, ie whatever you type. to stop typing, you give ctrl-d to cat and it will save what you type to filename. this is essentially the same as what you do with gedit (or other editors).
Originally Posted by milonix
However, if you just do a cat:
cat will echo what you type on the screen (stdout).Code:# cat this is first line this is first line
please look at the cat man page for more details.
- 04-22-2007 #8Just Joined!
- Join Date
- Apr 2007
- Posts
- 6
Thanks for everyone's help


Reply With Quote