Bash-interesting-command-examples: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 26: | Line 26: | ||
* Remove non-english directories | * Remove non-english directories | ||
* change the type to f if you are looking for non-english files | * change the type to f if you are looking for non-english files | ||
* ALWAYS test find results before deleting, duh! | |||
<pre> | <pre> | ||
sudo find . -type d -not -name "[a-zA-Z0-9]*" -exec rm -rf {} \; | sudo find . -type d -not -name "[a-zA-Z0-9]*" -exec rm -rf {} \; |
Latest revision as of 09:35, 27 March 2025
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/
- Remove non-english directories
- change the type to f if you are looking for non-english files
- ALWAYS test find results before deleting, duh!
sudo find . -type d -not -name "[a-zA-Z0-9]*" -exec rm -rf {} \;