cut
How to cut lines separated by multiple spaces?
How to get list of User-Agent from access log
To list all kernels available in your server, run
awk -F\' '$1=="menuentry " {print i++ " = "$2}' /etc/grub2.cfg
Example
root@server48 [~]# awk -F\' '$1=="menuentry " {print i++ " = "$2}' /etc/grub2.cfg 0 = CloudLinux (3.10.0-962.3.2.lve1.5.24.10.el7.x86_64) 7.6 (Vladimir Lyakhov) 1 = CloudLinux (3.10.0-962.3.2.lve1.5.24.9.el7.x86_64) 7.6 (Vladimir Lyakhov) 2 = CloudLinux (3.10.0-962.3.2.lve1.5.24.8.el7.x86_64) 7.6 (Vladimir Lyakhov) 3 = CloudLinux (3.10.0-962.3.2.lve1.5.24.5.el7.x86_64) 7.5 (Viktor Gorbatko) 4 = CloudLinux (3.10.0-962.3.2.lve1.5.24.4.el7.x86_64) 7.5 (Viktor Gorbatko) root@server48 [~]#
To print all users from /etc/passwd, run
cat /etc/passwd | awk -F: '{print $1}'
To list all file names from ls -l command, run
ls -l | awk -F' ' '{print $9}'
Leave a Reply