User Tools

Site Tools


bash_oneliners

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
bash_oneliners [2020/06/05 11:46]
admin
bash_oneliners [2020/06/10 17:26]
admin
Line 2: Line 2:
  
  
-  * Remove offending key from known_hosts file with one command 
-<code> 
-$ sed -i 18d .ssh/known_hosts 
-</code> 
   * Whats my WAN IP?   * Whats my WAN IP?
 <code> <code>
-dig +short myip.opendns.com @resolver1.opendns.com+dig +short myip.opendns.com @resolver1.opendns.com
 </code> </code>
   * Find large files, print 10 largest files in dir   * Find large files, print 10 largest files in dir
 <code> <code>
-find . -printf '%s %p\n'|sort -nr|head+find . -printf '%s %p\n'|sort -nr|head
 </code> </code>
   * size of all files older than mtime   * size of all files older than mtime
 <code> <code>
-find . -mtime +7 -print0 | du -hc --files0-from - | tail -n 1+find . -mtime +7 -print0 | du -hc --files0-from - | tail -n 1
 </code> </code>
   * To find the largest file in all sub-directories:   * To find the largest file in all sub-directories:
 <code> <code>
-find /path/to/folder -type f -exec ls -s {} \; | sort -nr | awk 'NR==1 { $1=""; sub(/^ /, ""); print }'+find /path/to/folder -type f -exec ls -s {} \; | sort -nr | awk 'NR==1 { $1=""; sub(/^ /, ""); print }'
 </code> </code>
   * grep for valid IP Addresses.   * grep for valid IP Addresses.
 <code> <code>
-grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" file.txt+grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" file.txt
 </code> </code>
   * show used inode count for subdirectories.   * show used inode count for subdirectories.
bash_oneliners.txt ยท Last modified: 2020/06/10 17:27 by admin