Skip to content

Instantly share code, notes, and snippets.

@yuchdev
Created June 23, 2022 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuchdev/ef0627f8f02fa8be57c66340b884c426 to your computer and use it in GitHub Desktop.
Save yuchdev/ef0627f8f02fa8be57c66340b884c426 to your computer and use it in GitHub Desktop.
Bash Code Snippets
#!/bin/sh
# Backup Partititon
dd if=/dev/sda of=/mnt/backup/sda.img conv=noerror
fdisk -l /dev/sda > /mnt/backup/sda.info
dd if=/dev/sdb of=/mnt/backup/sdb.img conv=noerror
fdisk -l /dev/sdb > /mnt/backup/sdb.info
# execute "git pull" in every dir
for dir in ~/projects/git/*
do
(cd $dir && git pull)
done
# find text 'text-to-find-here' in all files
find / -type f -exec grep -H 'text-to-find-here' {} \;
# Mount FTP as dir
mount -t nfs ftpback-rbx3-473.ovh.net:/export/ftpbackup/ns6663170.ip-151-80-105.eu /mnt/backup
mount -t cifs -o sec=ntlm,uid=root,gid=100,dir_mode=0700,username=root,password=fVnb79C4rG //ftpback-rbx3-473.ovh.net/ns6663170.ip-151-80-105.eu /mnt/backup
# add to *.tar only hidden directories
find -regex './\..*' | tar cvf ./test.tar -T -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment