Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Zadaca 1
- ---------------
- #!/bin/bash
- while getopts "scx:" c; do
- case $c in
- s)
- ls -l|grep "^-..x"|awk '{print $9;}'|grep ".sh\**$"
- broj=`ls -l|grep "^-..x"|awk '{print $9;}'|grep ".sh\**$"|wc -l`
- if [ $broj -le 0 ]
- then
- echo "Njama be brat, njama"
- fi
- ;;
- c)
- ls -l|grep "^-..x"|awk '{print $9;}'|grep ".c\**$"
- broj=`ls -l|grep "^-..x"|awk '{print $9;}'|grep ".c\**$"|wc -l`
- if [ $broj -le 0 ]
- then
- echo "Njama be brat, njama"
- fi
- ;;
- x)
- ls -l|grep "^-..x"|awk '{print $9;}'|grep "$OPTARG"
- broj=`ls -l|grep "^-..x"|awk '{print $9;}'|grep "$OPTARG"|wc -l`
- if [ $broj -le 0 ]
- then
- echo "Njama be brat, njama"
- fi
- ;;
- *) echo "nope"
- exit 2
- esac
- done
- -------
- Zadaca 2
- -------
- #!/bin/bash
- if [ $# -lt 2 ]
- then
- echo "Moras da imas navedeno tocno 2 argumenti, you shmuck"
- exit 2
- fi
- if [ !-d $1 ]
- then
- echo "Ne e validen prviot direktorium"
- exit 2
- fi
- if [ !-d $2 ]
- then
- mkdir $2
- fi
- cd $1
- ls -l | sed -n '/^-rw-/p' | sed \'s/^-rw-.*:[0-9][0-9] //'
- #echo $prom
- --------
- Zadaca 3
- --------
- #!/bin/bash
- if [ $# -le 0 ]
- then
- echo "glup si"
- exit 2
- fi
- if [ ! -d $1 ]
- then
- mkdir $1
- else
- rm -rf $1
- mkdir $1
- fi
- for file in *
- do
- if [ -d $file ]
- then
- continue
- fi
- ekstenzija=`echo $file | sed 's/^.*\.'//`
- echo $ekstenzija
- cd $1
- if [ ! -d $ekstenzija ]
- then
- mkdir $ekstenzija
- fi
- cd ..
- folder=`echo ${1}/${ekstenzija}`
- mv $file $folder
- done
- --------
- Zadaca 4
- --------
- #!/bin/bash
- if [ $# -lt 2 ]
- then
- echo "glup si"
- exit
- fi
- if [ ! -f $2 ]
- then
- touch $2
- fi
- broj=`echo $1`
- fajl=`echo $2`
- function fib {
- zbir=`expr $1 + $2`
- if [ $zbir -ge $broj ]
- then
- exit
- fi
- echo $zbir >> $fajl
- fib $2 $zbir
- }
- fib 1 1
- --------
- Zadaca 5
- --------
- #!/bin/bash
- argum=`echo $2`
- dokj=`echo $1`
- function grdarekurzija {
- if [ $1 -le $dokj ]
- then
- pret1=`expr $2 \* 2`
- pret2=`expr $pret1 - 1`
- echo "pravam $argum$1$pret2"
- mkdir $argum$1$pret2
- echo "pravam $argum$1$pret1"
- mkdir $argum$1$pret1
- lvl=`expr $1 + 1`
- echo "vlagam vo $argum$1$pret2"
- cd $argum$1$pret2
- grdarekurzija $lvl $pret1
- cd ..
- lvl=`expr $1 + 1`
- pret1=`expr $2 \* 2`
- pret2=`expr $pret1 - 1`
- cd $argum$1$pret1
- grdarekurzija $lvl $pret1
- cd ..
- fi
- }
- grdarekurzija 2 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement