Lesson - 19 : UNIX - Finding Files Commands in Unix

Опубликовано: 12 Октябрь 2024
на канале: Sada Learning Hub
112
2

Search all directories

Search file called httpd.conf in all directories:
$ find / -type f -name httpd.conf

Generally this is a bad idea to look for files. This can take a considerable amount of time. It is recommended that you specify the directory name. For example look httpd.conf in /usr/local directory:
$ find /usr/local -type f -name httpd.conf

Execute command on all files

Run ls -l command on all *.c files to get extended information :
$ find . -name "*.c" -type f -exec ls -l {} \;

You can run almost all UNIX command on file. For example, modify all permissions of all files to 0700 only in ~/code directory:
$ find ~/code -exec chmod 0700 {} \;

Search for all files owned by a user called payal:
$ find . -user <userid>
$ find . -user payal

Read find command man page for detailed information:
$ find(1)