0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
#!/bin/bash
prefix=$HOME"/crypthome"
pictures=(bmp jpg jpeg pgm rgb tga png gif ico)
docs=(rtf doc docx pdf txt)
html=(shtml html xml css htm xhtml xslt xls)
audio=(mp3 mp4 mpeg flv 3gp webm)
arch=(zip rar gz bz2 tar 7zip ar tar\.gz tar\.bz2 xz 7z)
pack=(deb rpm jar)
scripts=(sh pl py php js cpp c sql)
conf=(conf cfg)
torrent=(torrent)
an=""
mdt=""
function get_date
{
dt=`date`
pt1=${dt:4:7}
pt1=`echo $pt1 | tr [:space:] _`
echo $pt1
pt2=${dt:25:25}
echo $pt2
mdt=$pt1$pt2
echo $mdt
}
function recogn
{
recogn_arr=("$@")
for fname in ${recogn_arr[@]} ; do
if [ -f $fnm ]; then
rslt=`echo $an" "$fnm | grep -i \.$fname$`;
if [ -n "$rslt" ]
then
echo $rslt
if [ -d $prefix"/"$an ]; then
echo "dir" | ls -l $prefix"/"$an
cd $prefix"/"$an
pwd
else
mkdir $prefix"/"$an
fi
pc="Pictures"
if [[ $an == "Pictures" ]]; then
get_date
if [ -d $prefix"/"$an"/"$mdt ]; then
echo $prefix"/"$an"/"$mdt"/" | xargs -I {} mv $fnm {}
exit 1
else
mkdir -p $prefix"/"$an"/"$mdt
echo $prefix"/"$an"/"$mdt"/" | xargs -I {} mv $fnm {}
exit 1
fi
fi
echo $prefix"/"$an"/" | xargs -I {} mv $fnm {}
fi
else
echo "No file"
exit 1
fi
done
}
fnm=`find $1 -amin -1 | grep $2$`
echo $fnm
an="Pictures"
recogn "${pictures[@]}"
an="books"
recogn "${docs[@]}"
an="Downloads"
recogn "${html[@]}"
an="music"
recogn "${audio[@]}"
an="arch"
recogn "${arch[@]}"
an="pack"
recogn "${pack[@]}"
an="src"
recogn "${scripts[@]}"
an="conf"
recogn "${conf[@]}"
an="torrent"
recogn "${torrent[@]}"
Копирует файлы с определенным расширением в соответствующую директорию.
AliceGoth ,
21.06.2012 (Updated 25.03.2018 )
0
ReallyBugMeNot ,
05.06.2012 (Updated 25.03.2018 )
0
1
while true; do mail -s "foo@bar.com" ">_<"; done
Copy-Paste ,
04.06.2012 (Updated 25.03.2018 )
0
1
sed -e 's/""/"/g;s/^"//g;s/"$//g;s/";/;/g;s/;"/;/g'
Для любителей регулярок. Убирает экранирование строк в CSV.
bormand ,
30.05.2012 (Updated 25.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
while true
do
if [ $variable -le $null ]; then #### if then 1
vmm=`expr $vmm + 1`
if [ $vmm -eq `expr 13` ]; then
vmm=`expr 1`
fi
imm=`expr $imm - 1`
if [ $imm -eq $null ]; then
imm=`expr 12` vyy=`expr $vyy + 1`
fi
idd=`expr ${month[$imm]} + $variable`
if [ $idd -gt $null ]; then
if [ $imm -lt 10 ]; then
imm=0$imm
fi
if [ $idd -lt 10 ]; then
idd=0$idd
fi
calc_date=`expr $current_year - $vyy`$imm$idd
break;
else #### else 1
variable=`expr ${month[$imm]} + $variable`
fi
else
if [ $imm -lt 10 ]; then
vmm=0$imm
else
vmm=$imm
fi
if [ $variable -lt 10 ]; then
variable=0$variable
fi
calc_date=`expr $current_year - $vyy`$vmm$variable
break;
fi
done
echo $calc_date
#Альтернативный (нормальный) вариант
calc_date=`perl -e 'use POSIX;print strftime "%Y%m%d",localtime time-'$period*86400';'`
Дата и время в нужном формате
paa ,
30.05.2012 (Updated 25.03.2018 )
0
uiopqwertyasd ,
28.05.2012 (Updated 25.03.2018 )
0
1
d:/mingw/lib/gcc/../../x86_64-w64-mingw32/include/io.h:175:16: error: 'long long long' is too long for GCC
lebutirate ,
28.04.2012 (Updated 25.03.2018 )
0
1
ls -lb ${T} | tail -n$(ls | wc -l) | grep -e '^-' > file
govnomonad ,
27.04.2012 (Updated 25.03.2018 )
0
1 2 3 4
cat *.txt | while read a
do
echo $a | wc -c
done | sort -n | tail -n 1 | sed -e 's/[^0-9]//g'
возвращает размер самой длинной строки из всех txt-файлов в текущей папке
ksugltronteal ,
21.04.2012 (Updated 25.03.2018 )
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
sudo apache2 -V
Server version: Apache/2.2.20 (Ubuntu)
Server built: Nov 7 2011 22:48:05
Server's Module Magic Number: 20051115:28
Server loaded: APR 1.4.5, APR-Util 1.3.12
Compiled using: APR 1.4.5, APR-Util 1.3.12
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/apache2"
-D SUEXEC_BIN="/usr/lib/apache2/suexec"
-D DEFAULT_PIDLOG="/var/run/apache2.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="mime.types"
-D SERVER_CONFIG_FILE="apache2.conf"
geniewgen ,
08.04.2012 (Updated 25.03.2018 )