本文共 2418 字,大约阅读时间需要 8 分钟。
find . -name "*.tar" -exec mv {} /backup/ 注解:
find命令用于查找文件,-name "*.tar"指定了以.tar结尾的文件,-exec mv {} /backup/则将匹配的文件移动到指定目录。可以使用-type f限制为文件,避免误将目录包含。 for i in `find . -name "*.zip" -type f` do unzip -d /data/www/img/done $idone
注解:
find命令查找所有.zip文件,使用-type f确保只匹配文件。for循环遍历每个文件,使用unzip解压到指定目录。 .字符:sed -i 's/^.//g' test.txt
a字符:sed 's/^/a/g' test.txt
a字符:sed 's/$/a/' test.txt
sed '/wuguangke/ac' test.txt
sed '/wuguangke/ic' test.txt
sed -i 's:/user/local:/tmp:g' test.txt
if [ ! -d /data/backup/ ]; then mkdir -p /data/backup/else echo "The Directory already exists, please exit."fi
df -h | sed -n '/^Filesystem.*\/[^/]/p' | awk '{print $5}'while sleep 5; do df -h | sed -n '/^Filesystem.*\/[^/]/p' | awk '{print $5}' | sed 's/%//g' | awk '{if ($1 >= 90) then email...}'donecat access.log | awk '{print $1}' | sort | uniq -c | sort -nr | head -20 注解:
sort排序后uniq -c去重统计,sort -nr按访问量降序排列,head -20显示前20条。 sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
sed -i 's:/user/local:/tmp:g' test.txt
awk 'BEGIN {max=0} {if ($1+0 > max+0) max=$1} END {print "Max=" max}'awk 'BEGIN {min=65536} {if ($1+0 < min+0) min=$1} END {print "Min=" min}'cat test.txt | awk '{sum+=$1} END {print "Sum=" sum}'snmpwalk -v2c -c public 192.168.0.241
sed -e 's/jk$/yz/g' b.txt
tcpdump -nn host 192.168.56.7 and port 80
tcpdump -nn host 192.168.0.22 and port 80
cat .bash_history | grep -v ^# | awk '{print $1}' | sort | uniq -c | sort -nr | head -20 find . -mtime +3 -name "*.log" | xargs rm -rf {} find . -size +100k -exec mv {} /tmp/ iptables -Fiptables -A INPUT -p tcp --dport 80 -j ACCEPTiptables -A INPUT -p tcp -j REJECT
cat access.log | awk '{print $1}' | sort -n | uniq -c | sort -nr -k1 | head -10 nc -vz 192.168.1.2 8080
nc -u 192.168.1.2 8080
nc -l -p 8080
nc -l -p 8080 | pv
(A端)
nc 192.168.1.2 8080 < /dev/zero
(B端)
转载地址:http://rkpi.baihongyu.com/