You've been tasked with writing a script that processes input arguments. How would you check if the number of arguments provided to the script is less than 3?
- if [ "$#" -lt 3 ]
- if [ "$#" -eq 3 ]
- if [ "$#" -gt 3 ]
- if [ "$#" -eq 0 ]
To check if the number of arguments provided to the script is less than 3, you would use if [ "$#" -lt 3 ]. This tests whether the number of script arguments, represented by $#, is less than 3. Option 2 checks if the number of arguments is exactly 3, and Option 3 checks if it's greater than 3. Option 4 checks if there are no arguments.
Loading...
Related Quiz
- To temporarily save iptables rules, one would use the command iptables-save > ________.
- What is the primary use of the iptables -L command?
- If you want to view detailed information about disk usage for each directory, the __________ command would be appropriate.
- Which Samba tool is used for checking the configuration file for errors?
- You're debugging a script and notice that an operation splits a string incorrectly. You suspect it might be related to the field separator. Which built-in variable should you check?