Hi guys, I need to know if there is a "and if" statement. Because I need to compare the 1st variable and 2nd variable at the same time and im not sure how to do it.
I tried something like this:
if [ "$1" = '' ]
then
find . -type f -size +10k -ls
elif [ "$2" = '' ]
then
find . -type f -size +"$1"k -ls 2>/dev/null
else
exit 1
fi
I am not sure if this is correct or not. I have tried it and im not getting the output that i want.
The first variable wants the size of the file, and the 2nd variable wants the directory name.
In this case, im trying to use the find command. I want to compare if the 1st variable is empty and if the 2nd variable is empty at the same time. So if they are both empty, do this :
find . -type f -size +10k -ls
And then, after this i want some statement to check if the user input something in 1st variable and in the 2nd variable, i want it to check if the 2nd variable ( in this case its the directory name) even exist.
So I tried something like this:
I am not sure if this is correct and i am kind of confused about exit statement, when do I use them?
if [ -d "$2" ]
then
find "$2" -type f -size +"$1"k -ls 2>/dev/null
else
echo 'The specified directory does not exist' >&2
exit 1
fi
Please correct my statements.
Thank you