- 1
- 2
- 3
- 4
- 5
- 6
am=`cat $file | wc -l`
for ((i=1;i<=$am;i++))
do
read z
imsi=`echo $z | sed -e "s/^[0-9]*[ ]*//" `
done < $file
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−127
am=`cat $file | wc -l`
for ((i=1;i<=$am;i++))
do
read z
imsi=`echo $z | sed -e "s/^[0-9]*[ ]*//" `
done < $file
−134
# Fallback static file handler, now with XSendfile support.
if not if(test -f $local_path) {
if(! ~ $#xsendfile 0) {
if(! ~ $#xsendfile_alternate 0)
XSendfileHeader='X-Accel-Redirect'
if not
XSendfileHeader='X-Sendfile'
echo $XSendfileHeader': '`{pwd}^'/'$local_path
}
if not
static_file $local_path
}
if not if(~ $req_path /pub/* && test -f .$req_path) {
if(! ~ $#xsendfile 0) {
if(! ~ $#xsendfile_alternate 0)
XSendfileHeader='X-Accel-Redirect'
if not
XSendfileHeader='X-Sendfile'
echo $XSendfileHeader': '`{pwd}^'/'$req_path
}
if not
static_file .$req_path
}
−133
#!/bin/bash
cat -b $1 > file.txt
sed -e 's/^/<br>/g' -i file.txt
curl --data-urlencode [email protected] netelis.hmsite.net/upload.php | head -n1
Аналог wgetpaste
−139
#!/bin/bash
export cpx=0
export cpy=0
cf=0
export xf=0
export yf=0
while :
do
tput reset
xp=`cat /tmp/X.txt`
yp=`cat /tmp/Y.txt`
echo "xp $xp yp $yp"
clear
if [ $cpx -eq $xp ]
then
echo "x coincided"
xf=1
elif [ $cpx -gt $xp ]
then
let cpx--
else
let cpx++
fi
if [ $cpy -eq $yp ]
then
echo "y coincided"
yf=1
elif [ $cpy -gt $yp ]
then
let cpy--
else
let cpy++
fi
tput cup 45 130
echo px $xp py $yp
tput cup 46 130
echo x $cpx y $cpy
tput cup $cpx $cpy
sleep 0.5s
if [ $xf -eq 1 ]
then
if [ $yf -eq 1 ]
then
echo "Point coincide"
exit
fi
fi
done
Move cursor in right place.
−132
#!/bin/bash
export k=1
export g=0
export i=1
export j=1
handle_terminatem() {
let k=-1
let g=0
}
handle_terminatep() {
let k=1
let g=0
}
handle_terminategp() {
let g=1
let k=0
}
handle_terminategm() {
let g=-1
let k=0
}
echo pid $$
trap handle_terminatem 2 3
trap handle_terminatep 20 19 9
trap handle_terminategp 31
trap handle_terminategm 1
while :
do
tput clear
tput cup $i $j
echo "$1 $k $g"
if [ $j -gt 0 ]
then
let "j+=k"
else
let j=1
fi
if [ $i -gt 0 ]
then
let "i+=g"
else
let i=1
fi
sleep 0.1s
done
Управляет сигналами положением слова курсора на экране.
−118
xxx: Знакомый попал в дтп, спорная ситуация, отдал гайцам флешку из регистратора, опечатали в конверт.
xxx: Гайцы внимательно изучили - признали невиновность по ДТП, и за одно наштрафовали на много тысяч по 4 случаям записанным на флешке и в конце концов лишили прав за встречку, записанную в начале дня.
−130
echo "Ghbdtn? rfr ltkf&" | sed "s/.*/\L&/;y|f,dult~;pbqrkvyjghcnea[wxioms]'.z&?|абвгдеёжзийклмнопрстуфхцчшщьыъэюя?,|"
Транслирует английскую раскладку в русскую.
−137
find . -type f -exec sed -i 's^`/bin/date -v1d -v-1d "+%Y-%m-%d"`^`/bin/date --date "$(date +%m/01/%Y) yesterday" +%Y-%m-%d`^g;s^`/bin/date -v1d "+%Y-%m-%d"`^`/bin/date --date "$(date +%m/01/%Y)" +%Y-%m-%d`^g;s^`/bin/date -v+1m -v1d -v-1d "+%Y-%m-%d"`^`/bin/date --date "$(date +%m/01/%Y) + 1month - 1day" +%Y-%m-%d`^g;s^/bin/date -v-2d ^/bin/date --date "$(date +%m/%d/%Y) -2day" ^g;s^/bin/date -v-7d ^/bin/date --date "$(date +%m/%d/%Y) -7day" ^g;' {} \;
−131
#!/bin/bash
######################################################################################
#
# Write a bash script that obtains active processes for the current user,
# breaks them into chains and prints all unique chains containing 3 or more
# PIDs in the following format:
# PID1:PID2:PID3:…:PIDn
# PID:PID:PID:…:PID
# …
# So that each next PID is a parent of the previous PID, the first PID in
# each chain does not have children and the last PID in each chain
# does not have parent.
#
######################################################################################
TEMPFILE="/tmp/$0$$" # file needs to save the process list
# it's really needed to divide columns
# generated 'ps'
# parameters:
# -H - sorts the list as process forest (it lets to find connection between child and parent faster)
# -o - sets the output format
# "%p %P" - thow columns in output: PID and PPID
# -u - sets username
# `whoami` - get the current user name
ps -H -o "%p %P" -u `whoami` > $TEMPFILE
PIDLIST=(`awk '/[0-9]/ {print $1}' $TEMPFILE`) # make an array using the first column
PPIDLIST=(`awk '/[0-9]/ {print $2}' $TEMPFILE`) # and the second
SIZE=${#PIDLIST[*]}
K=0
# bypassing the forest using stack which emulates LINKS array. K is the pointer to stack's top
for (( i=0; i<$SIZE; i++ ))
do
if [[ $K = 0 || ${PPIDLIST[$i]} = ${LINKS[$K-1]} ]] # new tree or new edge in the tree.
then
LINKS[$K]=${PIDLIST[$i]} # push PID to stack
K=`expr $K + 1`
else # the chain is complete.
if [[ $K > 2 ]] # enough size to print the chain
then # reversed formatted output the chain
echo ${LINKS[*]} | awk '{ printf $NF; for (i = NF-1; i > 0; --i) printf ":"$i}'
echo
fi
until [[ $K == 0 || ${PPIDLIST[$i]} == ${LINKS[$K-1]} ]]
do # deleting elements from stack until find a
# parent or tree is end
unset LINKS[$K-1]
K=`expr $K - 1`
done
LINKS[$K]=${PIDLIST[$i]} # push PID to stack
K=`expr $K + 1`
fi
done
rm -rf $TEMPFILE # removing temp file
−137
#!/bin/bash
num=30
while :
do
lns=`aureport -f -i --summary | wc -l`
aureport -f -i --summary | wc -l
if [ $num -gt $lns ]
then
num=0
fi
aureport -f -i --summary | head -n$num | tail -n30 | ./mkbar files
let "num=num+30"
echo $num
sleep 1s
done
Выводит аудит файлов в виде диаграммы по 30 файлов за раз.