create list of all files in every subdirectories in bash create list of all files in every subdirectories in bash bash bash

create list of all files in every subdirectories in bash


There is a very easy way of doing this with find:

find . -type f -exec md5 {} \;

The command finds all files (-type f), and executes the command md5 on each file (-exec md5 {} \;).


There is also a program called tree, but you can simulate it with only shell builtins:

#!/bin/shDIR=${1:-`pwd`}SPACING=${2:-|}cd $DIRfor x in * ; do    [ -d "$DIR/$x" ] &&  echo "$SPACING\`-{$x" && $0 "$DIR/$x" "$SPACING  " || \    echo "$SPACING $x : MD5=" && md5sum "$DIR/$x"done

Note it requires a full path argument (or none for current directory)

Its not as fast as find (though there are plenty of ways to speed it up that make the code more complicated to follow), but gives a graphical representation of the tree structure.You can modify it to not follow symlinks by adding- && [ ! -L "$DIR/$x" ] or to only list directories: remove the || echo $SPACING $x