find / -name "ru_RU*" -exec ls {} \;
find . -name '*.html' | xargs ls -l
find /dir/ -name "*.tar" -a -mtime +60 -delete
# rpm -qa| head -n 4
basesystem-8.0-5.1.1.el5.centos
centos-release-notes-5.3-3
words-3.0-9.1
glibc-2.5-34
# rpm -qa| head -n 5 | awk -F"-" '{print $1}'
basesystem
centos
words
glibc
perl -pi -e 's/foo/bar/g'То же самоое только создать бекап:
perl -pi.bak -e 's@foo@bar@g'
# rpm -qa | perl -ne 'print if s/-\d+.*//g' | head -n 4 centos-release-notes mailcap audit-libs glib2
for i in `seq 1 20`; do (echo $i; sleep $i) & done
# ls -1
eth0
eth0-2.root
eth0-2:10.ssh
eth0-2:30.default
# for i in `find . -type f -name "eth0*"` ; do echo ${i/eth0/eth1}; done
./eth1-2:30.default
./eth1-2.root
./eth1
./eth1-2:10.ssh
find . -type f | while read F; do
newname=`echo $F | tr 'a-z' 'A-Z'`
mv "$F" "$newname"
done
find . -name '*.html' | xargs perl -pi -e 's/windows-1251/utf-8/g'
for i in `find . -name '*.html'`; do
cat $i | iconv -f windows-1251 -t UTF-8 > tmp.txt ; echo 'yes' | mv tmp.txt $i;
done
export malware='something here' egrep -lr "$malware" | xargs perl -pi -e "s/$malware//g"
egrep '([0-9]{1,3}\.){3}[0-9]{1,3}'
В каждом логе '*.log' текущей директории заменить на месте любой IP на указанный:
find . -name "*.log" | xargs perl -pi -e 's@^([0-9]{1,3}\.){3}[0-9]{1,3}@1.2.3.4@'
# IP=1.2.3.4; IP=(${IP//./ }); Rev=${IP[3]}.${IP[2]}.${IP[1]}.${IP[0]}
# echo $Rev
4.3.2.1
Here's an example that uses the old IFS variable (the "inter-field separator in the Bourne, and Korn shells as well as bash) to parse each line of /etc/passwd and extract just two fields: # cat /etc/passwd | tail -n 2 test:x:503:507::/home/test:/bin/bash openvpn:x:102:106:OpenVPN:/etc/openvpn:/sbin/nologin # cat /etc/passwd | tail -n 2 | (IFS=:; while read n1 n2 n3 n4; do echo "$n1 $n3" ;done) test 503 openvpn 102
ifconfig | grep -n1 eth0 | tail -n1 | awk '{print $3}' | sed -e 's/addr://'
perl -p -i -e 's/$/\r/ filename
| Sergej A. Kandyla sk.paix at gmail.com Any comments and suggestions are welcome. |
|