Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.



Question

In linux, write one-line script to create new directory ktest (in current directory) ONLY if ktest does not already exist. Do it by finishing following code snippet:

ls ktest >& /dev/null [...]

Answer

|| mkdir ktest

^^ note use of || to denote only if command 1 (i.e. ls ktest >& /dev/null) fails, command 2 (i.e. mkdir ktest) runs


Question

In linux, write one-line script to create new directory ktest (in current directory) ONLY if ktest does not already exist. Do it by finishing following code snippet:

ls ktest >& /dev/null [...]

Answer
?

Question

In linux, write one-line script to create new directory ktest (in current directory) ONLY if ktest does not already exist. Do it by finishing following code snippet:

ls ktest >& /dev/null [...]

Answer

|| mkdir ktest

^^ note use of || to denote only if command 1 (i.e. ls ktest >& /dev/null) fails, command 2 (i.e. mkdir ktest) runs

If you want to change selection, open document below and click on "Move attachment"

20. Advanced Shell Scripting
do with the bash shell. 20.1 Lists of Commands The special operator && and || can be used to execute functions in sequence. For instance: grep '^harry:' /etc/passwd || useradd harry The <span>|| means to only execute the second command if the first command returns an error. In the above case, grep will return an exit code of 1 if harry is not in the /etc/passwd file, causing us

Summary

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Details

No repetitions


Discussion

Do you want to join discussion? Click here to log in or create user.