ryu's blog just a few lines of code

15Apr/111

Replace a string in a file in CLI (Command Line), Linux

For instance, you would like to replace 'abc' with 'def' everywhere in your file, do the following:

cat file1.txt | sed -e 's/abc/def/' > file2.txt

12Mar/100

Check CPU virtualization capability on Linux

egrep '(vmx|svm)' --color=always /proc/cpuinfo

8Feb/100

MySQL Dump Backup-Rotation

#!/bin/bash

TIME1=$(date +%d_%m_%Y__%H_%M_%S)
user="root"
passwd="xxxxxx"

# blabla db
db="blabla"
mysqldump -c -f -Q --user=${user} --password=${passwd} --host=localhost ${db} | gzip -f > /root/backup/db_${db}.$TIME1.sql.gz
find /root/backup/db_${db}.*.sql.gz -mtime +3 -exec rm {} ;

Tagged as: , , No Comments