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

$ cat > ispostive
#!bin/sh
#
# Script to see whether argument is postive
#
if test $1 -gt 0
then
echo "$1 number is postive"
fi

just so everyone knows i just started to learn shell scripting :)

That's an interesting use of cat. Anyways, I tried running it, and it worked fine after a small change (you didn't put a / before bin/sh, so working from anywhere other than the / directory would not work).

output:

jimmy@vera ~/code/bash $ ./ispositive 4
4 number is postive
jimmy@vera ~/code/bash $ ./ispositive -4
jimmy@vera ~/code/bash $ ./ispositive 1234567890
1234567890 number is postive
jimmy@vera ~/code/bash $ ./ispositive 0

thanks :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.