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
Next revision
Previous revision
bash_oneliners [2018/04/23 14:31]
admin
bash_oneliners [2020/06/10 17:27] (current)
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> 
 +  * size of all files older than mtime 
 +<code> 
 +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 -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.1524486684.txt.gz · Last modified: 2018/04/23 14:31 by admin