tkaczanowski

bash shell utils

Oct 10th, 2011
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.66 KB | None | 0 0
  1. #gzip
  2. gzip file.txt // this replaces file.txt with file.txt.gz
  3. gzip -d file.txt.gz // this replaces file.txt.gz with file.txt
  4.  
  5. #recursive directory size
  6. du -hs directory
  7.  
  8. #find 10 biggest in directory tree
  9. find . -ls | sort -rn +6 -7 | head -10
  10.  
  11. #remove empty directories
  12. find -depth -type d -empty -exec rmdir {} \;
  13.  
  14. #do something in every dir
  15. for file in *; do
  16.   if [ -d $file ]; then
  17.       echo $file
  18.       mkdir -p -v $file/src/{test,main}/java/com/practicalunittesting;
  19.   fi
  20. done
  21.  
  22. #filename with current date / timestamp
  23. cp file.txt whatever_`date +"%Y%m%d_%H%M"`.txt
  24.  
  25. #recover from dump
  26. psql -h my.db.server -U userName -d dbName < sql_dump.sql
Advertisement
Add Comment
Please, Sign In to add comment