I am trying to get the filenames for all the files listed in my current directory for current date and list them into a new file in same path.
#!/bin/bash
for file in /queues/intermediate/outbound/*EXP_GP_$(date %Y-%m-%d)* do f1=`basename $file`
if [ -f "$file" ];then
cat >> All_Name $f1;
else
echo "no files to collect"
done
CodePudding user response:
this works
find -maxdepth 1 -mtime -1 | grep -v bash | grep / | sed 's/\.\///' > FileList.txt
CodePudding user response:
Try this:
#!/bin/bash
for file in /queues/intermediate/outbound/\*EXP_GP_$(date %Y-%m-%d)\*
do
f1=`basename $file`
if [ -f "$file" ]; then
cat >> All_Name $f1;
else
echo "no files to collect"
fi
done
There was also a 'fi' missing.