1

I have this command :

echo rm $(find "$SD" -type f -mtime "+$MT" -name "*.$TY" -print ) >> ${LOGFILE}

and it prints

rm /u01/oradata/logs/dwf_monitor_datafile.dbf.gz /u01/oradata/logs/dws_monitor_datafile.dbf.gz /u01/oradata/logs/dwd_monitor_datafile.dbf.gz

I want it to instead print

rm /u01/oradata/logs/dwf_monitor_datafile.dbf.gz 
rm /u01/oradata/logs/dws_monitor_datafile.dbf.gz 
rm /u01/oradata/logs/dwd_monitor_datafile.dbf.gz

How, thanks in adcance.

1 Answer 1

3

If you actually want to delete the files, you should use find's -delete command. If you are just trying to display nice-looking output, then try:

find "$SD" -type f -mtime "+$MT" -name "*.$TY" -exec echo rm {} \; >>${LOGFILE}
Sign up to request clarification or add additional context in comments.

2 Comments

I am already doing that, I just want to generate this code for a manual delete later on. Something that you cut from the log and paste onto command line and run the actuals. The data may change thats why.
@user1918074 Did you try the find command in my answer for that? In what way was its output not satisfactory for your purposes?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.