Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.2 kB
2
Indexable
Never
#!/bin/bash

#Papai Csaba-Zsolt, 513/2-es csoport, pcim2171
#shell1 - 2-es feladat

#megnezzuk ha megfelelo-e a melyseg
if [ $# -lt 2 ]
then
        echo "$0 [melyseg] [katalogus(ok)]"
        exit 1
fi

#lementjuk a melyseget
depth=$1

#kitoljuk a parametereket
shift
shift

#megnezzuk ha katalogus-e
for directory in $*
do
        if [ -d directory ]
        then
                echo "$0 [melyseg] [katalogus(ok)]"
                exit 1
        fi
done

#megoldas
for directory in $*
do
        for file in `find $directory -maxdepth $depth -type f`
        do
                #irasjogot adunk
                chmod a+w $file

                #kiirjuk hogy hol talalhato
                echo "$directory katalogus `readlink -f $file`-ban talalhato"

                if [ `wc -l $file` -lt 5 ]
                then
                        cat $file
                elif [ `wc -l $file` -lt 10 ]
                then
                        head -n 5 $file
                else
                        head -n 2 $file
                        echo "..."
                        last -n 2 $file
                fi
                echo "-----------------------------------"
        done
done