Skip to main content

Good day

I am writing this script that have this line:

ls -lrt /dir1/dir2/filename*.txt | tail -1 | awk '{print $9}' | read variable

What I wanted is to exit the script (without using if-statement) if it does not find any match.

Thank you.

Good day

I am writing this script that have this line:

ls -lrt /dir1/dir2/filename*.txt | tail -1 | awk '{print $9}' | read variable

What I wanted is to exit the script (without using if-statement) if it does not find any match.

Thank you.

I am writing this script that have this line:

ls -lrt /dir1/dir2/filename*.txt | tail -1 | awk '{print $9}' | read variable

What I wanted is to exit the script (without using if-statement) if it does not find any match.

Source Link

exit a script if an ls line did not find any match

Good day

I am writing this script that have this line:

ls -lrt /dir1/dir2/filename*.txt | tail -1 | awk '{print $9}' | read variable

What I wanted is to exit the script (without using if-statement) if it does not find any match.

Thank you.