Aquí hay una solución:
outputPath='/path/to/output/'
for file in $(find ~/filesToSort/ -type f -name "ff*")
do
firstLine=$(head -n 1 $file)
datePath="${firstLine//-//}"
mkdir -p $outputPath$datePath
mv $file $outputPath$datePath
done
Básicamente, este script hace:
Es posible que desee agregar una prueba para asegurarse de que la primera línea coincida con la plantilla requerida.
только для /exploit
bdf /exploit | awk 'NR==2 { printf "%d\n",$5 ;}
для любой файловой системы
bdf | awk '{printf "%3d %s\n",$5,$6}'
примечание
%s
вместо %d
, чтобы вернуть %
знак... %d %%