Wednesday, March 20, 2019

Copy file preserving directory structure in Linux

Use cp --parents /d1/d2/d3/f4 /e1/e2/e3 to get the copy /e1/e2/e3/d1/d2/d3/f4.

[Courtesy: this]

Monday, January 21, 2019

Grepping specific files recursively

To search the pattern PAT in all csv and csv.bak files in the directory DIR and its subdirectories, do

grep --include=*.csv* -ER "PAT" DIR

[Courtesy: this]