Linux Shell的一些使用小技巧收集

2019-09-23 09:32:23于丽


nmap -p 8081 172.20.0.0/16

设置git email:

git config --global user.email "me@example.com"

To sync with master if you have unpublished commits:

git pull --rebase origin master

将所有文件名中含有”txt”的文件移入/home/user目录:

find -iname "*txt*" -exec mv -v {} /home/user ;

将文件按行并列显示:

paste test.txt test1.txt

shell里的进度条:

pv data.log

使用netcat将数据发送到Graphite server:

echo "hosts.sampleHost 10 `date +%s`" | nc 192.168.200.2 3000

将tabs转换成空格:

expand test.txt > test1.txt

Skip bash history:

< space >cmd

去之前的工作目录:

cd -

拆分大体积的tar.gz文件(每个100MB),然后合并回去:

split –b 100m /path/to/large/archive /path/to/output/files
cat files* > archive

使用curl获取HTTP status code:

curl -sL -w "%{http_code}n" www.example.com -o /dev/null

设置root密码,强化MySQL安全安装:

/usr/bin/mysql_secure_installation

当Ctrl + c不好使时:

Ctrl +

获取文件owner:

stat -c %U file.txt

block设备列表:

lsblk -f

找出文件名结尾有空格的文件:

find . -type f -exec egrep -l " +$" {} ;

找出文件名有tab缩进符的文件

find . -type f -exec egrep -l $'t' {} ;

用”=”打印出横线:

printf '%100sn' | tr ' ' =