Tuesday, November 11, 2014

RSYNC using filter to include some files

use rsync with Filter option to include some files.

For example:


rsync -auvz -f'+ [Aa][Mm]*'  -f'+ */' -f'- *' /SOURCE-Folder/ /TARGET-Folder/



It means: exclude all files and include only files beginning with A and M (insensitive).

Wednesday, November 5, 2014

Add line to the beginning of a file in Bash

To add a line to the beginning of a file, use this command: 
 
sed -i '1s/^/YOUR NEW LINE\n/' YOUR-FILE.TXT