본문 바로가기

LINUX/기초

리눅스 명령어! 가장 중요한 기초부터 자연스레 알게되는 명령어까지!

 


 

locate는 디렉토리를 뒤지는게 아니라 데이터베이스에서 직접 찾음. 그래서 빠름

+ (locate가 사용하는 데이터베이스를 mlocate라고 부름)

 

디렉토리를 직접 뒤지는 것은 find

 

find 사용법 35가지 - www.tecmint.com/35-practical-examples-of-linux-find-command/

 

35 Practical Examples of Linux Find Command

The Linux Find Command is one of the most important and frequently used command command-line utility in Unix-like operating systems. Find command is used to search and locate the list of files and directories based on conditions you specify for files that

www.tecmint.com

 

Usage: find [-H] [-L] [-P] [-Olevel] [-D debugopts] [path...] [expression]

 

[path...] : 어떤 디렉토리에서부터 찾을건지 [.] [/] [~/ubuntu/] 등등..

[expression] : 내가 찾고자 하는 파일을 어떤 형태로 찾을 건지 [-name] [-iname] 등등..

 

예제

find . -name tecmint.txt

현재 디렉토리 밑으로 이름이 tecmint.txt 인 것을 찾음.

 

find ~ -type f -name "tecmint.txt" -exec rm -f {} \;

home 디렉토리[ ~ ] 밑으로 타입은 파일이고[ -type f ] 이름[ -name ]이 tecmint.txt인 것을 찾아.

그리고 제거해[ -execute rm ]. 묻지말고[ -f ] 아까 찾은 애를[ {} ]