tail -n 13 history |awk '{print $2,$3,$4,$5,$6,$7,$8.$9,$10}'提取第2到第11列

# cat history |awk '{print $2,$3,$4,$5,$6,$7,$8.$9,$10}'

# tail -n 13 history
215 systemctl stop
216 systemctl stop xinetd
217 systemctl stop firewalld
218 systemctl disable firewalld
219 vim neokylin.repo
220 yum install -y *tigervnc*
221 vncserver :55
222 history
223 history |cut 2
224 cd /home/
225 mkdir pxe-cut
226 cd pxe-cut/
227 history >>history
[root@localhost pxe-cut]# tail -n 13 history |awk '{print $2,$3,$4,$5,$6,$7,$8.$9,$10}'
systemctl stop
systemctl stop xinetd
systemctl stop firewalld
systemctl disable firewalld
vim neokylin.repo
yum install -y *tigervnc*
vncserver :55
history
history |cut 2
cd /home/
mkdir pxe-cut
cd pxe-cut/
history >>history

# tail -n 13 history |awk '{print $2,$3,$4,$5,$6,$7,$8.$9,$10}'
systemctl stop
systemctl stop xinetd
systemctl stop firewalld
systemctl disable firewalld
vim neokylin.repo
yum install -y *tigervnc*
vncserver :55
history
history |cut 2
cd /home/
mkdir pxe-cut
cd pxe-cut/
history >>history

 
原文地址:https://www.cnblogs.com/xuanbjut/p/12978929.html