TIME NOW
World current time now,
CALENDAR
Calendar monthly, yearly
login CONVERT LENGTH
login CONVERT TEMPERATURE
login DICTIONARIES, LISTS
login SCIENCE EDUCATION RELIGION
login WORK CALCULATOR
login CALCULATE LIFE

Linux commands, scripts, examples, tutorial

Previous articlePage bottomNext article  ALL TOPICS

Linux. If Condition example - bash sample

 This code changes permissions:
#!/bin/sh

b=1

while [ $b ]
do


clear; echo File name ; read a

[ -e $a ] || ( touch $a; echo File created )


if test -d $a
then

    echo This is folder

else

    echo "Choose plus x - taip, minus x - ne"
    read b
    
    if test $b = "taip"
    then
        chmod a+x $a
        echo Added
    else
        chmod a-x $a
        echo Removed
    fi
fi

sleep 3

done

Check size and delete:
SIZE="1048576"
DIRSIZE=$(du -bs /home/kolegija/Desktop/b  | awk '{print $1}')

if [ "$DIRSIZE" -gt "$SIZE" ]; then
       echo "didesnis";
        rm -rf /home/kolegija/Desktop/b/*
else
        echo "mazesnis"
fi

Previous articlePage topNext article  ALL TOPICS



 Use username: Guest, Anonymous, Programmer






QUOTES:
You're always happy in a competitive bidding situation. And I don't think it's over yet.
John Orrico
Prosperity is no just scale; adversity is the only balance to weigh friends.
Plutarch
An involuntary return to the point of departure is, without doubt, the most disturbing of all journeys.
Iain Sinclair