Facebooktwittergoogle_plusredditpinterestlinkedinmail

List files and directories inside the specified path

Some time we want to check list all files in a directory recursively. But its hard to navigate each and every directory to check all the files. Here are the simple commands which will help you to check all the files and directories available in a specific path.

$ find -L "/path/to/directory" -type f


If you don’t want to search in specific directory then you can also restrict your search result from below command.

Exclude specific directories

$ find -L "/path/to/directory" -type f -and -not -path "*/.git*"

In my example I have excluded .git directory from my listing criteria.

Shell Script to list files recursively

checkfile.sh

#!/bin/sh
dir=""
if [ -d "$1" ]; then
dir=$1;
else
echo "Please directory path as a argument."
exit 0
fi
files="$(find -L "$dir" -type f -and -not -path "*/.git*")"
echo "$files" | while read file; do
     echo "$file"
done

Uses:

sh checkfile.sh /path/to/directory
Get the List of All Files and Directory Recursively in Linux Roopendra Vishwakarma Linux,
List files and directories inside the specified path Some time we want to check list all files in a directory recursively. But its hard to navigate each and every directory to check all the files. Here are the simple commands which will help you to check all the files and...
<h3>List files and directories inside the specified path</h3> Some time we want to check list all files in a directory recursively. But its hard to navigate each and every directory to check all the files. Here are the simple commands which will help you to check all the files and directories available in a specific path. <pre>$ find -L "/path/to/directory" -type f</pre>If you don't want to search in specific directory then you can also restrict your search result from below command.<strong>Exclude specific directories</strong> <pre>$ find -L "/path/to/directory" -type f -and -not -path "*/.git*"</pre> In my example I have excluded .git directory from my listing criteria.<a href="http://techieroop.com/tag/shell/#.VpHoAfl97cc" target="_blank">Shell Script</a> to list files recursively<strong>checkfile.sh</strong> <pre>#!/bin/sh dir="" if [ -d "$1" ]; then dir=$1; else echo "Please directory path as a argument." exit 0 fi files="$(find -L "$dir" -type f -and -not -path "*/.git*")" echo "$files" | while read file; do echo "$file" done</pre> <strong>Uses:</strong> <pre>sh checkfile.sh /path/to/directory</pre>
(Visited 238 times, 17 visits today)
Facebooktwittergoogle_pluslinkedinrss