User:Krikko: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 13: | Line 13: | ||
if [ ! $(expr substr $2 1 1) = $(expr substr $oigused 1 1) ] | if [ ! $(expr substr $2 1 1) = $(expr substr $oigused 1 1) ] | ||
then | then | ||
echo 2 | |||
fi | fi | ||
if [ ! $(expr substr $2 2 1) = $(expr substr $oigused 2 1) ] | if [ ! $(expr substr $2 2 1) = $(expr substr $oigused 2 1) ] | ||
then | then | ||
echo 3 | |||
fi | fi | ||
if [ ! $(expr substr $2 3 1) = $(expr substr $oigused 3 1) ] | if [ ! $(expr substr $2 3 1) = $(expr substr $oigused 3 1) ] | ||
then | then | ||
echo 4 | |||
fi | fi | ||
#faili ei leitud | #faili ei leitud |
Revision as of 13:46, 12 May 2011
#faili olemasolu
if [ -e "$1" ];
then
#faili õigused numbrilisel kujul
oigused=$(stat -c %a $1)
#faili ja sisendi õigused samad
if [ $oigused = $2 ];
then
exit 0
fi
#õigustest substring ja nende võrdlemine
if [ ! $(expr substr $2 1 1) = $(expr substr $oigused 1 1) ]
then
echo 2
fi
if [ ! $(expr substr $2 2 1) = $(expr substr $oigused 2 1) ]
then
echo 3
fi
if [ ! $(expr substr $2 3 1) = $(expr substr $oigused 3 1) ]
then
echo 4
fi
#faili ei leitud
else
exit 1
fi