shell学习命令总结

ls /var/log/audit -Ftr | grep /$ | tail -1

查看文件夹以/结尾的文件,并取倒数第一个值

cp -r /var/log/audit/\`**ls /var/log/audit -Ftr | grep /$ | tail -1**` /home/fsp/last_audit_result

取符号中间命令的输入作为输入

事先植入变量,并在下一条命令中截取

NETWORK_ID=$(neutron net-list | grep external_om | awk '{ print $2}') 
neutron port-list --network-id=$NETWORK_ID | wc -l neutron port-list

awk取值

ll /sys/dev/block/ | grep -w dm-4$ | awk '{print $8}'

匹配字符串所在的列**Use%**然后打印

df -h |  awk 'BEGIN {idx = 0;} {if (FNR == 1) {for (i = 1; i <= NF; i++) {if($i == "Use%") {idx = i;}}} else {print $idx;}}'

你可能感兴趣的:(linux)