воскресенье, 21 августа 2011 г.

Unlimited random bash.org.ru quotes without advertisement


while true
do
w3m http://bash.org.ru/random/|egrep -v "(zadolbali|adview|смешно.*утверждена)"|sed '1,10d'|sed -e :a -e '$d;N;2,10ba' -e 'P;D' >> abyss
done

* смешно.*утверждена - (funny.*approved, russian)

^C
w3m abyss



вторник, 16 августа 2011 г.

Test duplicate gate interface address in local networks

ip -o addr|egrep "L.* inet"|
while read t eth t ip t
do
echo -n "Test duplicate address "${ip%%/*}" via "$eth": "
  RES=$(arping -D ${ip%%/*} -I $eth -c 1 2>&1)
[ $? = 0 ] && echo OK || echo FAIL
done

понедельник, 15 августа 2011 г.

Last.fm like insert

Execute it in your player root directory and get your charts like on last.fm :D


find -type f|sed -e 's/\.\///;s/ - .*//;s/[0-9]*\.//;s/.*\///;s/^\s//'|egrep -v "(mp3|html|jpg|jpeg|png|nfo|bmp|^[0-9])"|sort|uniq|awk '{print $ALL","}'|tr '[:upper:]' '[:lower:]'|while read f; do echo -n ${f^}" "; done; echo

пятница, 12 августа 2011 г.

ps in style of windows taskmgr

p="(`echo $@ | tr ' ' "|"`)"
ps axv|egrep "$p"|awk '{print $7"\t"$10}'|sort -nr

usage:

$ sh que.sh bash gnome
1181749 gnome-panel
523226 /usr/lib/gnome-settings-daemon/gnome-settings-daemon
334838 gnome-terminal
328194 /usr/lib/gnome-panel/wnck-applet
305068 /usr/lib/gnome-applets/trashapplet
299039 gnome-session
299035 gnome-session
299035 gnome-session
275984 /usr/lib/gnome-panel/notification-area-applet
272433 /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1
181419 gnome-screensaver
179311 gnome-session
108883 /usr/bin/gnome-keyring-daemon
98892 /usr/lib/gdm/gdm-simple-slave
28520 bash
26377 /usr/bin/dbus-launch
14612 gnome-pty-helper
14187 egrep
12092 /usr/bin/ssh-agent
4120 sh

четверг, 11 августа 2011 г.

Simple examples of grep (egrep, fgrep)

#!/bin/bash
echo -n 'Enter word: '
read word

#in all params of script calling
for i in $@                            
do

        #looking for word at the beginning of string

egrep ^$word $i  
        #looking for word at the end of string
        egrep $word$ $i
        #looking for strings without words windows, dos OR gates



        egrep -v "(windows|dos|gates)"         
done

среда, 10 августа 2011 г.

понедельник, 8 августа 2011 г.

SCP Example

scp -P 33 root@192.168.5.1:/var/backup/db/daily_2011-08-09_04-12.gbk ~/backup.gbk

33 - ssh port of remote machine
192.168.5.1 - remote machine address
/var/backup/db/daily_2011-08-09_04-12.gbk - remote file to download
~/backup.gbk - local file to save


scp -P 33 backup.gbk root@192.168.8.1:/var/backup/db/daily_2011-08-09_04-12.gbk

33 - ssh port of second remote machine
192.168.8.1 - second remote machine address
/var/backup/db/daily_2011-08-09_04-12.gbk - remote file to save
backup.gbk - local file to upload

четверг, 4 августа 2011 г.

Fast change mac-address via bash

#!/bin/bash
export mac=`ifconfig|grep eth0|tr -s ' '|cut -d ' ' -f5`
export command=""
if [ "$mac" != "52:54:00:e4:55:46" ]
    then command="ifconfig eth0 hw ether 52:54:00:e4:55:46"
    else command="ifconfig eth0 hw ether 52:54:00:e4:55:47"
fi
ifconfig eth0 down
sleep 1;
$command
sleep 1;
ifconfig eth0 up

понедельник, 1 августа 2011 г.