I have a script and in the script I am running the below command.
ls -1tr ${ARCH1_DIR}/* | grep ${LOG_PREFIX} > $copied_binlog_set
if the folder is empty I get an error.
ls: cannot access /n01/mysqlarch1/*: No such file or directory
The script at this point stops processing. Is there a way so the script can carry on processing if the folder is empty.
You can try:
ls -1tr ${ARCH1_DIR}/* 2>/dev/null | grep ${LOG_PREFIX} > $copied_binlog_set
When you write 2> file, it redirect stderr to file, but you can use the null device and throws the input it gets. You can think about it as the black hole of your system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With