Skip to content

Instantly share code, notes, and snippets.

@yuchdev
Last active January 7, 2020 07:47
Show Gist options
  • Save yuchdev/cf37532ce3e10ae6f36e543d538389e4 to your computer and use it in GitHub Desktop.
Save yuchdev/cf37532ce3e10ae6f36e543d538389e4 to your computer and use it in GitHub Desktop.
Bash examples
#!/bin/sh
# Execute for every subdir
for dir in ~/projects/git/*
do
(cd $dir && git pull)
done
Find text
find / -type f -exec grep -H 'text-to-find-here' {} \;
# recurse delete all .svn
find . -name .svn -print0 | xargs -0 rm -rf
# tar only hidden directories
find -regex './\..*' | tar cvf ./test.tar -T -
# crontab - lock xfce screen hourly
50 9-22 * * * root /usr/bin/xflock4
# tar directory
tar -zcvf prog-1-jan-2005.tar.gz /home/jerry/prog (gz)
tar -jcvf prog-1-jan-2005.tar.gz /home/jerry/prog (bz2)
# untar file
tar -zxvf yourfile.tar.gz
# find text in file
find . -type f -exec grep -H 'text-to-find-here' {} \;
# find several extensions
????
# Every directory size in root
find . -maxdepth 1 -type d \( ! -name . \) -exec bash -c "du -h -d 0 '{}'" \;
# Search files by text
grep -lr 'строка' /путь
# Install deb-package
sudo dpkg -i package.deb
# Create DVD image
dd if=/dev/cdrom of=/tmp/cdimg1.iso
# Burn DVD image:
growisofs -Z /dev/cdrom=/home/ycherkasov/images/ubuntu.img
# Catalog size
du -ks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment