0

I use find to get the path to my directory and I want to use sed to redact ALL the files under the directory that have been modified more than n days

I run this: find "$path" -type f -mtime +$days -exec sed -i.bak -E -f redact.sed {} \;.

$path: path to current directory.
$days number of days since lost modified.

What is wrong with this? More specifically, I don't know what to put after redact.sed to get it to run all files under the directory.

bull
  • 61
  • Didn't you just ask https://unix.stackexchange.com/questions/611891/how-to-use-exec-option-with-find which was closed as a duplicate? What isn't working? What is in the redact.sed script? – icarus Sep 29 '20 at 02:13
  • @icarus this is asking how to use find to run all files in a directory, the link you're talking about is asking how to use -exec command with sed. so no, completely different question – bull Sep 29 '20 at 02:21
  • the redact.sed just takes a number and replaces it with %, but I want to do it for all files under directory specify in $path – bull Sep 29 '20 at 02:22
  • 1
    This may be executing sed -i.bak -E -f redact.sed redact.sed - running the sed script on itself could be a problem. – rowboat Sep 29 '20 at 03:26
  • why did you write redact.sed twice? – bull Sep 29 '20 at 03:49
  • What are the values of $path and $days? Btw, $path is an unfortunate name for a variable, as it can be easily confused with $PATH. – rexkogitans Sep 29 '20 at 06:28
  • It's amazing how similar this (the above) is to this. Is this homework? – G-Man Says 'Reinstate Monica' Sep 29 '20 at 06:48
  • assume $days is 2 and $path to be user/file/redact – bull Sep 29 '20 at 06:53

0 Answers0