0

My cleanup script that logs what i deleted.

log=$HOME/Deleted/$(date)
find $HOME/OldLogFiles/ -type f -mtime -7 -exec ls -latr {} \; -exec echo was deleted on `date` \; -exec rm -f "{}" \;|paste - - >> $log

I keep getting these errors however...

./test.sh: line 3: $log: ambiguous redirect
find: ‘ls’ terminated by signal 13
find: ‘ls’ terminated by signal 13

Anybody have any suggestions?

mkrouse
  • 277
  • 2
  • 4
  • 11

1 Answers1

0

It seems the "ambigous redirect" is because the log variable contains spaces. You need to add quotes around it ("$log"). Check out Getting an "ambiguous redirect" error. This causes the paste command to finish early, closing the pipe that ls writes to, which in turn leads to the ‘ls’ terminated by signal 13 errors.

That said, you might want to use a custom date format in the date command (maybe date -I?). Check out the man page for date.

Community
  • 1
  • 1
ctn
  • 2,887
  • 13
  • 23