case ${NUMBER} in
[0-9]|[0-6][0-9]|7[0-5])
echo "${NUMBER} <= 75"
;;
[7-8][0-9]|9[0-5])
echo "75 < ${NUMBER}<=95"
;;
[9][5-9]|100)
echo "95< ${NUMBER} <=100"
;;
esac
Search This Blog
Monday, September 17, 2007
Shell scripting: case statement & numbers
Selecting a numeric range with the case statement.
Thursday, May 17, 2007
Shell scripting: Testing empty variables
$V="xNotEmpty" if [ x$V = "xNotEmpty" ] then echo "\$V not empty" else echo"\$V is empty" fi Or: if [ "$V" = "" ] then echo "\$V is empty fi
Wednesday, May 16, 2007
awk
Using shell variables with awk.
1. awk "/$func/"'{print $0}' filename
2. awk -v pat=$func '/pat/{print $0}' filename
Using fields in search pattern
For a similar match:
1. awk '$1~/pattern/{print $0}' filename
For a precise match:
2. awk -F":" -v user=$U '$1 == user {print $0}' filename
1. awk "/$func/"'{print $0}' filename
2. awk -v pat=$func '/pat/{print $0}' filename
Using fields in search pattern
For a similar match:
1. awk '$1~/pattern/{print $0}' filename
For a precise match:
2. awk -F":" -v user=$U '$1 == user {print $0}' filename
Tuesday, March 20, 2007
Perl command line.
Using multiple perl commands on the command line.
perl -n -e 'perl cmd;'\
-e 'perlcmd'
Invoke the split command
perl -n -a -e 'cmd'
-n Places a loop around the command line.
perl -n -e 'perl cmd;'\
-e 'perlcmd'
Invoke the split command
perl -n -a -e 'cmd'
-n Places a loop around the command line.
Subscribe to:
Posts (Atom)