Last active
August 29, 2015 14:00
-
-
Save knyga/11175250 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
DateDir=`date +"%d.%m.%Y"` | |
createdir() | |
{ | |
if [ ! -d $1 ] | |
then | |
mkdir $1 | |
fi | |
} | |
#CREATING DIR WITH DATE | |
if [ -d $DateDir ] | |
then | |
rm -rf $DateDir | |
fi | |
createdir $DateDir | |
#CREATING DIRS | |
for i in `seq 1 9` | |
do | |
createdir $DateDir"/task"$i | |
done | |
#CREAING FILES UTF8 | |
for i in `echo "man ls touch cp mv mkdir rm rmdir chmod cat ln find date ps tar"` | |
do | |
if [ ! -f $DateDir/task1/$i.utf8.txt ] | |
then | |
$i --help > $DateDir/task1/$i.utf8.txt | |
$i --help >> $DateDir/task1/manual.utf8.txt | |
fi | |
done | |
#CREAING FILES CP1251 | |
for i in `ls $DateDir/task1` | |
do | |
fname=`echo $i | awk -F. '{print $1}'` | |
if [ ! -f $DateDir/task2/$fname.cp1251.txt ] | |
then | |
iconv -f utf8 -tcp1251 $DateDir/task1/$fname.utf8.txt > $DateDir/task2/$fname.cp1251.txt | |
fi | |
done | |
#LINKS FOR A COMMAND DESC | |
for i in `ls /usr/share/doc/` | |
do | |
if [ ! -s $DateDir/task3/$i ] | |
then | |
ln -s /usr/share/doc/$i $DateDir/task3/$i | |
fi | |
done | |
#CHMOD | |
for level0 in `seq 0 7` | |
do | |
for level1 in `seq 0 7` | |
do | |
for level2 in `seq 0 7` | |
do | |
touch $DateDir/task4/$level0$level1$level2.txt | |
chmod $level0$level1$level2 $DateDir/task4/$level0$level1$level2.txt | |
accname=`ls -l $DateDir/task4/$level0$level1$level2.txt` | |
#$accname=$accname"str"; | |
_accname=`echo $accname | awk -F' ' '{print $1}'` | |
mv $DateDir/task4/$level0$level1$level2.txt $DateDir/task4/$_accname.txt | |
done | |
done | |
done | |
#/ETC | |
for etcEntity in `ls /etc/` | |
do | |
etfile1=`echo $etcEntity | awk -F'.' '{print $1}'` | |
etfile2=`echo $etcEntity | awk -F'.' '{print $2}'` | |
len=${#etfile2}; | |
if [ "$len" -gt "0" ] | |
then | |
if [ ! -f $DateDir/task5/[info]$etfile1.$etfile2.txt ] | |
then | |
info /etc/$etfile1.$etfile2 >> $DateDir/task5/[info]$etfile1.$etfile2.txt | |
cp /etc/$etfile1.$etfile2 $DateDir/task5/ | |
fi | |
else | |
if [ ! -s $DateDir/task5/$etfile1 ] | |
then | |
ln -s /etc/$etfile1 $DateDir/task5/$etfile1 | |
fi | |
fi | |
done | |
#FIND CONF | |
for _conf in `find /usr/share/ -name "*.conf"` | |
do | |
cp $_conf $DateDir/task6/ | |
done | |
#FIND AND STRUCTURIZE | |
cd $DateDir/task7/ | |
(cd /usr/share; find -type d ! -name .) | xargs mkdir | |
cd ../.. | |
for _conf in `find /usr/share/ -name "*.conf"` | |
do | |
export VAR=$_conf | |
export DIR=$(dirname ${VAR}) | |
localname=${DIR/'/usr/share/'/''} | |
cp $_conf $DateDir/task7/$localname | |
done | |
#TARS | |
tar -cvf $DateDir/task8/task1.tar $DateDir/task1 | |
tar -cvzf $DateDir/task8/task2.tar.gz $DateDir/task2 | |
tar -cvjf $DateDir/task8/task3.tar.bz2 $DateDir/task3 | |
zip -r $DateDir/task8/task4.zip $DateDir/task4 | |
rar a $DateDir/task8/task6.rar $DateDir/task6 | |
`echo du $DateDir/task1` >> $DateDir/task8/size.txt | |
`echo du $DateDir/task8/task1.tar` >> $DateDir/task8/size.txt | |
`echo du $DateDir/task2` >> $DateDir/task8/size.txt | |
`echo du $DateDir/task8/task2.tar.gz` >> $DateDir/task8/size.txt | |
`echo du $DateDir/task3` >> $DateDir/task8/size.txt | |
`echo du $DateDir/task8/task3.tar.bz2` >> $DateDir/task8/size.txt | |
`echo du $DateDir/task4` >> $DateDir/task8/size.txt | |
`echo du $DateDir/task8/task4.zip` >> $DateDir/task8/size.txt | |
`echo du $DateDir/task6` >> $DateDir/task8/size.txt | |
`echo du $DateDir/task8/task6.rar` >> $DateDir/task8/size.txt | |
#COPY TO TASK9 =) | |
cp ${0%/*} $DateDir/task9/ | |
: <<'END' | |
$ export VAR=/etc/abrt/abrt.conf | |
[juline@(none) Рабочий стол]$ export DIR=$(dirname ${VAR}) | |
[juline@(none) Рабочий стол]$ echo ${DIR} | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment