0

I want to delete files in a directory, from the supplies csv file if its older than 1 day.

I tried to print them for test purpose:

in.txt

1,one
2,two

code:

 INPUT="in.txt"
 while IFS=',' read -r id name
 do
   find tmp/$name -mtime +1 -type f
 done < "$INPUT"

This code throws error :

find: bad status-- tmp/one
find: bad status-- tmp/two

Thanks.

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
user2711819
  • 960
  • 3
  • 16
  • 29

1 Answers1

0

recall that the form for a find command is

 find ${baseDir} -${options ......} args to opts.

Your form is saying

find tmp/$name -mtime +1 -type f
# --^^^^^^^^^^ -- start looking in dir tmp/$name

You probably want to say

find tmp -name $name -mtime +1 -type f
#---^^^^^ start looking in the tmp dir

Keeping the -type f may not be needed, but it prevents you from matching a directory instead of a file.

IHTH.

shellter
  • 36,525
  • 7
  • 83
  • 90