I am using the find command on a number of directories stored in
fdir array to execute
head on each file. How can I adapt the code so users can also include files as well as directories?
Code:
hn=8
nf=${#fdir[@]}
for (( i=0 ; i < $nf ; i++ )); do
find "${fdir[$i]}" -type f \
-exec head -v -n "$hn" '{}' +
done
I could put both directories and files in
fdir so things are straightforward, the user simply passes a list of directories and files.
For instance, I can use the find command for directories, whilst calling head directly for files.