Friday, January 26, 2018

Create and extract a .tar.gz archive using command line


To create a tar.gz archive from a given folder you can use the following command:

tar -zcvf tar-archive-name.tar.gz source-folder-name

This will compress the contents of source-folder-name to a tar.gz archive named tar-archive-name.tar.gz

To extract a tar.gz compressed archive you can use the following command:

tar -zxvf tar-archive-name.tar.gz

This will extract the archive to the folder tar-archive-name.

To Preserve permissions:

tar -pcvzf tar-archive-name.tar.gz source-folder-name

Switch the ‘c’ flag to an ‘x’ to extract (uncompress):

tar -pxvzf tar-archive-name.tar.gz

Reference:
https://popoleodesigns.com/create-and-extract-a-tar-gz-archive-using-command-line/

Friday, January 19, 2018

How do I find all files containing specific text on Linux?

grep -rnw '/path/to/somewhere/' -e 'pattern'  
or

    grep -r YOUR_PATTERN .
or
find /path/to/somewhere -type f -exec grep -H 'text-to-find-here' {} \;

Reference:
https://stackoverflow.com/questions/16956810/how-do-i-find-all-files-containing-specific-text-on-linux