bash if
eharetea

If statement in bash using the test statement.

Useful if and or statements for shell scripts.

Date Created:Friday December 29th, 2006 03:41 AM
Date Modified:Friday March 13th, 2009 08:53 PM


#!/bin/bash


if [ "$2" ]
then 
echo Too many args!
exit
fi

if [ -"$1" ]
then
ssh somename@3daet.com
else
ssh $1@3daet.com
fi






// this checks to see if a file exists

if [ -s index2.php ];
then echo blah;
else echo blue;
fi;








dir=`echo $PWD | sed 's@/@ @g' | awk '{print $NF}'`
 if [ $dir=="Displacement" ] || [ $dir=="Surface" ]
 then
   file=$DHM/houdini8.1/shop/SHOP`echo $dir|tr '[A-Z]' '[a-z]'|sed 's@ment@@g'`
 else
   file=$VEX/VEX`echo $dir|tr '[A-Z]' '[a-z]'`
 fi





Downloads:
Download: if.sh 148 B
Download: or.sh 256 B
Download: fileexists.sh 112 B

Please login or Click Here to register for downloads
Creative Commons License
bash if by Dan Lynch
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
Based on a work at www.3daet.com
Permissions beyond the scope of this license may be available at http://www.3daet.com