Home / Linux  / Linux “Find” Command And Its Usage

Linux “Find” Command And Its Usage

Spread the love

Search file with command .Below command will search file (named.conf) in current directory and sub directories.

# find . -name "named.conf" -print

Note : -print option wil print out the path of any file that meets the find criteria.

Find with multiple ‘-exec’ option.

# find  / -name  *.php" -exec echo {} \; -exec grep techtransit {} \;

find with -exec {} and way to count the total files .

# find / -name "*.php" -exec chmod 755 {} \; -exec /bin/echo {} \; | wc -l

OR

We can add -print option to find, instead of executing “/bin/echo{}” like below.

# find / -name "*.php" -print -exec chmod 755 {} \; | wc -l

Move or copy files print by ‘find’ command

find /path -type f -name "filename" | xargs cp -t /target_path

OR

find /path -name "filename"  -exec cp -rfp {} /destination_path  \;

Spread the love

Sachin is Red Hat Linux Certified and Freelance Contributor and Love to work and write on Open Source and Cloud Technologies .

})(jQuery)