Missing Semester - (2)

황수정·2021년 1월 4일
0

Missing Semester

목록 보기
2/7

[강의] https://www.youtube.com/watch?v=kgII-YWo3Zw&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&index=2
[강의 노트] https://missing-semester-kr.github.io/2020/shell-tools/

셀 툴과 스크립팅

특수 변수

변수할당: "" & ''

echo $?


정상종료되었다면 0, 아니라면 오류코드 1 출력

or (||) and (&&) 연산자

or (||)

첫번째 연산의 결과가 조건에 맞지 않으면 두번째 연산 실행
(연산결과는 true이기 때문에(종료코드0) 1에서는 첫문장이 맞지 않아 두번째 실행. 2에서는 일치하므로 두 번째 실행X)

and (&&)

첫번째 연산의 결과가 참이어야만 두번째 실행

; : 같은 라인에서 ;(세미콜론)을 사용하면 뒤는 항상 실행

{ } : 확장

touch foo{, 1, 2, 10}
touch foo foo1 foo2 foo10

touch {foo,bar}/{a..j}
touch foo/a foo/b ... foo/j bar/a bar/b ... bar/j

cp project{1,2 ?? 이거 하는 법??

diff

foo 디렉토리와 bar 디렉토리의 목록을 비교해라
: foo에는 x가 있고 bar에는 y가 있음

[tool] tldr => ffmpeg, tar ...
설치 완료!

find .


type d : 디렉토리 f : 파일

-path '**/test/*.py'

앞에 얼마나 디렉토리가 있던 신경쓰지 않고 test폴더 안의 .py파일만 찾음

모든 .tmp파일을 삭제해라
출력이 없어도 $?의 결과가 0이므로 잘 실행되었다는 뜻.
다시 .tmp파일을 찾아보면 결과가 없다.

[tool] fd => ??

locate ' '

' '이 이름에 포함된 모든 파일을 검색

[find 와 locate 비교]

[출처] https://unix.stackexchange.com/questions/60205/locate-vs-find-usage-pros-and-cons-of-each-other
[2차 출처] http://blog.daum.net/rayolla/1034

locate:
uses a prebuilt database, which should be regularly updated, while find iterates over a file system to locate files.
Thus, locate is much faster than find, but can be inaccurate if the database -can be seen as a cache- is not updated(see updatedb command).
Also, find can offer more granularity, as you can filter files by every attribute of it, while locate uses a pattern matched against file names.

locate 명령 사용전에 updatedb로 db를 업데이트

$ sudo updatedb

$ locate your_file

grep

[참고] https://recipes4dev.tistory.com/157
ripgrep (rg)
[참고]https://github.com/lazypic/tdcourse/blob/master/docs/find_grep.md

profile
알고리즘 , 웹 공부 중인 개발자 지망생

0개의 댓글

관련 채용 정보