File searching and Remove the searched files in Unix/Linux shell

When it comes to Linux/Unix operating system, you can use shell.


1. Identify detail information of files

>>> ls -l


2. Identify detail information of files including sub folders

>>> ls -lR

or

>>> ls -lRs


3. Search files which begin with test

>>> ls -lRs | grep -i test*

by using '-i' option, you can display the information of location (folders)


or


>>> find . -name 'test*' -print

this would be searching from this present folder


4. Search files which begin with test and then remove all or them

>>> find . -name 'test*' -exec rm {} \;

-exec command ;       : Execute command.
{}                         : The string {} is replaced by the current file name
\                         : For escaping


5. Some other usage

>>> find . -type d -exec chmod 755 {} ';

From this present folder, change all of folder's permission to 755


>>> find . -type f -exec chmod 644 {} ';

From this present folder, change all of files' permission to 644

댓글

이 블로그의 인기 게시물

미국 포닥, 한국으로 돌아가는 이유? (Why do postdoc go back to Korea?)

미국 포닥 - 비지팅 포닥 VS 풀펀딩 포닥 (Visiting Scholar VS Postdoctoral Fellow)

미국 포닥 직위, 타이틀, 명칭? - Visiting Scholar, Postdoctoral Fellow, Research Associate, Research Scientist, Research Professor