Aqui está um script que irá gerar este arquivo e imprimi-lo bem com printf.
Apenas chame como: ./script_name.sh /path/to/docfiles/
#!/usr/bin/env bash
docFiles=$(find "$1" -iname '*.doc')
numFiles=$(echo -e "$docFiles" | wc -l)
sep="--------------------------------------------------------------------------------"
Date="Date: $(date +'%d/%m/%Y')"
Count="Count : $numFiles"
# Start printing file
echo $sep
echo $Date
echo $Count
echo $sep
printf ' %-10s | %-10s | %-33s | %-15s |\n' "ID" "Host" "md5sum" "Created"
echo $sep
for file in $docFiles
do
docMD5=$(md5sum "$file" | awk '{ print $1 }')
# This was a bit unclear in the question...
# if you want file mtime instead... use something like:
#docDate=$(stat -c %d/%m/%Y "$file")
#docDate=${docDate%% *}
docID=$(basename "$file" | sed -e 's/^\(.*\)_.*//')
docHost=$(basename "$file" | sed -e 's/^.*_\(.*\)\.doc$//')
# Use today's date
docDate=$(date +"%d/%m/%Y")
printf ' %-10s | %-10s | %-33s | %-15s |\n' "$docID" "$docHost" "$docMD5" "$docDate"
done
echo $sep
- Copie / cole com seu editor favorito qualquer nome de arquivo que você quiser chamá-lo.
-
chmod +x script_name.sh
-
./script_name.sh /path/to/docfiles/