13
rated 0 times
[
13]
[
0]
/ answers: 1 / hits: 8089
/ 2 Years ago, tue, may 10, 2022, 8:12:07
I need to check if a folder is empty or not and according to the output I need to run some other commands. I'm working on Ubuntu 18.04.5 LTS.
My bash script:
if [ "$(ls -A /mnt/mamdrive/"As Metadata"/)" ] || ["$(ls -A /mnt/mamdrive/"As Video"/)" ]; then
echo "copy file"
else
echo "dont copy"
fi
The condition works sometimes, but sometimes it doesn't and it's hard to reproduce it. Is there any other way to check if the directory is empty and do some action accordingly?
More From » command-line