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?)

미국 포닥 월급 생활비, 일리노이 텍사스 포닥 (Illinois, Texas Postdoc Living Cost)

J1 미국 포닥, 미국 영주권 (EB2) 신청 및 승인 후기 (첫번째. J1 비자)