grep -nrw --include=\*.{py,R} "pattern_to_find" ./

-r             : recursively find

--include   : files to include

--exclude   : files to exclude

-n                : print with line number

-i                 : case-insensitive

-w                : only show word match

-c                 : count the matches in file 

-l                  : only show matching files




> find             : output every file and folder into stdout


===tests======================================


-type d[f]         : find directory / file

-name     "*.sra"  : find file name of the format

-iname    "*.SRA"  : case insensitive name

-path     "*.sra"  : *.sra 패턴이 filename 뿐만 아니라 path에도 적용됨

-and  = -a

-or   = -o         : ex) find -name "*.sra" -or -name "*.fa"

-not  = \!         : ex) find -not -name "*.bam"

   여기서 operation 순서를 지정해 주려면 () 대신 \( \) 사용

   ex) find \( -name "*.sra" -type f \) -or -type d

-maxdepth 1        : 1일 시 현재 directory

-depth             : find의 결과 list에서 folder의 content가 folder보다 먼저 나오게 함



===actions====================================


-print                 : default option

-delete                : 해당 파일/폴더를 삭제

-exec command {} \;    : find 의 결과가 {}의 자리에 들어가서 command 가 실행된다.


출처: https://math2001.github.io/post/bashs-find-command/





'Programming' 카테고리의 다른 글

[python] Passing function with partial arguments  (0) 2019.09.25
[Linux] 메모리 관리  (0) 2018.05.22
R 기초  (0) 2018.01.24
[linux][펌] ctags 사용법  (0) 2017.09.26
[python] .pyc 파일은 무엇일까?  (0) 2017.09.26

+ Recent posts