# cat test.txt | tac
# rev test.txt
# ping baidu.com | tee -a /tmp/output.txt
只过滤当前目录的第一层目录中,类型是文件并且修改时间是 3 天前的,统计其文件大小。
# find . -maxdepth 1 -mtime +3 -type f -print0 | xargs -0 du -sh
查找当前目录下以 txt 或 conf 结尾的文件。
# find ./ -regex ".*\.txt\|.*\.conf"
# ls -l | awk ‘/txt$/{sum+=$5}END{print sum}‘
# dstat -lmcdrnt
要显示的随机数是 1 到 100 之间,而且一次只显示其中 5 个随机数。
# shuf -i 1-100 -n 5
分别使用 grep、sed、awk 来过滤 httpd.conf 配置文件中的空行和以 # 开头的注释行。
# grep -E -v "^#|^$" /etc/httpd/conf/httpd.conf
# sed -e ‘/^$/d‘ -e ‘/^#/d‘ /etc/httpd/conf/httpd.conf
# awk ‘!/^#|^$/‘ /etc/httpd/conf/httpd.conf
随机生成 10 位字符串的三种方式。
# date +%s%N | md5sum | cut -c -10
# echo $RANDOM | md5sum | cut -c 1-10
# </dev/urandom tr -dc ‘a-zA-Z0-9!@#$%^&*()_+‘ | head -c 10
原文:https://blog.51cto.com/liubin0505star/2739144