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, if you have variable NAME, print out "hello NAME", and if NAME is not defined/set, print out: "hello there". Do this in one line of code (i.e. NO if statements/etc).
Answer

echo "hello ${NAME:-there}"

^^ note the special use of parameter expansion above


Question
In linux, if you have variable NAME, print out "hello NAME", and if NAME is not defined/set, print out: "hello there". Do this in one line of code (i.e. NO if statements/etc).
Answer
?

Question
In linux, if you have variable NAME, print out "hello NAME", and if NAME is not defined/set, print out: "hello there". Do this in one line of code (i.e. NO if statements/etc).
Answer

echo "hello ${NAME:-there}"

^^ note the special use of parameter expansion above

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

20. Advanced Shell Scripting
everal parameter expansion tricks that you can use to do string manipulation. Most shell programmers never bother with these, probably because they are not well supported by other UNIX systems. <span>${ VAR :- default } This will result in $ VAR unless VAR is unset or null, in which case it will result in default. ${ VAR := default } Same as previous except that default is also assigned to VAR if it is

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.