Bash-interesting-command-examples: Difference between revisions
Jump to navigation
Jump to search
(Created page with "====Interesting one-liners==== * Find all drives and ignore loop devices <pre> root@kvm03:/var/log# lsblk | grep -v "loop\|NAME" | grep "^[a-z]\|^[A-Z]" | awk '{print $1}' sda...") |
mNo edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 8: | Line 8: | ||
</pre> | </pre> | ||
<pre> | |||
root@kvm03:/var/log# lsblk | grep disk | awk '{print $1}' | |||
sda | |||
sdb | |||
root@kvm03:/var/log# | |||
</pre> | |||
Continue match until match is found | |||
* This is using awk, and seems quite powerful as a tool | |||
* found this little gem at [https://unix.stackexchange.com/questions/21076/how-to-show-lines-after-each-grep-match-until-other-specific-match Stack Exchange] | |||
<pre> | |||
awk '/Word A/,/Word D/' filename | |||
/From/CONTINUE/Until/ | |||
</pre> | |||
Latest revision as of 08:30, 4 July 2023
Interesting one-liners
- Find all drives and ignore loop devices
root@kvm03:/var/log# lsblk | grep -v "loop\|NAME" | grep "^[a-z]\|^[A-Z]" | awk '{print $1}' sda sdb root@kvm03:/var/log#
root@kvm03:/var/log# lsblk | grep disk | awk '{print $1}' sda sdb root@kvm03:/var/log#
Continue match until match is found
- This is using awk, and seems quite powerful as a tool
- found this little gem at Stack Exchange
awk '/Word A/,/Word D/' filename /From/CONTINUE/Until/