有用的命令行

来源:互联网 发布:螃蟹秘密内裤 知乎 编辑:程序博客网 时间:2024/05/29 17:28
Random order:
     cat gui*.txt | cut -c 1-11  | grep 1 |sort |  uniq| while read i; do echo "$i $RANDOM"; done | sort -k2n | cut -d " " -f1| grep -v -e "^182" | split -l 50000 -d -a2

Delete blank lines:
     cat httpd.conf.bak.20120411 | grep -v "#" | sed -e '/^\n$/d' | sed /^[[:space:]]*$/d >httpd.conf

Delete duplicate lines:
     cat 1.txt | cut -c 1-11 | sort |  uniq >1-result.txt

Filter a file with another file:
     grep -v -Fx -f black_user.csv hn-all  >hn.txt
     grep -v -Fx -f black_user.csv ln-all | grep -v -e "^182" >ln.txt

Wget
     wget ftp://sibmes1:1234abcd@intracx21.cathaypacific.com//export/home/webappaix13/repos/log/xmlibe2.2/Performance.log.2012-01-17.backup.gz -c /home/hike/temp.gz

Date
     Format:date --date "4 day" '+%Y-%m-%d'
     Last Day of Month:cal | tail -2 | head -1 | awk '{print $NF}'
     Diff:
          echo $(($(date -d '2004-01-09' +%j)-$(date -d '2004-01-05' +%j)))
          echo $((($(date +%s)-$(date -d 2011-12-01 +%s))/86400))
tar/bz2
tar   jxvf   linux-2-4-2.tar.bz2
tar -zxvf /tmp/etc.tar.gz 
ps
          ps -aux

netstat
         netstat -ant
    
Sed
          cat 7th.htm | grep reverseAuthorize | cut -d"(" -f2| cut -d")" -f1 | sed -e s/\',\'\'//g | sed -e s/\'//g | split -40 -d -a4

awk
     cat 1.sql | sed -e s/\(/,/g | sed -e s/\)/,/g | awk -F "," '{print $2"="$7" and " $3"="$8" and "$4"="$9}'
     cat 1.sql | sed -e s/\(/,/g | sed -e s/\)/,/g | awk -F "," '{print "select * from "$2"="$7" and " $3"="$8" and "$4"="$9}'      

端口号  

     netstat -nltp |grep 端口号或服务名
0 0
原创粉丝点击