Bash: a few bash commands

### Find all php files from the current folder down with 'LOOKINGFOR' content ###
find . -name '*.php' -print0 | xargs -0 grep 'LOOKINGFOR'

### Database backup and import ###
mysqldump -u ACCOUNT -pPASSWORD --databases DATABASE1 DATABASE2 DATABASE3 --complete-insert --extended-insert=false > FILE.sql
mysql -u ACCOUNT -pPASSWORD DATABASENAME < FILE.sql

### Checking a log file content live ##
tail -f /var/log/httpd/error_log

### Tar and untar ###
tar -cvzf FILENAME.tgz FOLDERNAME
tar -xvzf FILENAME.tgz

### Delete files that name matches 'MATCHPATTERN' ###
find . -name 'MATCHPATTERN' -exec rm -f '{}' ;

### SCP ###
scp LOCALFILENAME USERNAME@REMOTEHOST:/REMOTEFOLDER/FILENAME

Leave a Reply