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 simple bash script that prints out all the command line arguments of the script no matter how many or few (e.g. if you run script test.sh as "./tests.sh one two three", it will print out "one\n two\n three")
Answer
#!/bin/bash
while [ "$1" != "" ]; do
    echo $1
    shift
done
^^ note the use of shift
^^ also note the "$1" in the conditional clause of while loop (line 2) wrapped in "", as this is needed for string comparison!!!


Question
In linux, write simple bash script that prints out all the command line arguments of the script no matter how many or few (e.g. if you run script test.sh as "./tests.sh one two three", it will print out "one\n two\n three")
Answer
?

Question
In linux, write simple bash script that prints out all the command line arguments of the script no matter how many or few (e.g. if you run script test.sh as "./tests.sh one two three", it will print out "one\n two\n three")
Answer
#!/bin/bash
while [ "$1" != "" ]; do
    echo $1
    shift
done
^^ note the use of shift
^^ also note the "$1" in the conditional clause of while loop (line 2) wrapped in "", as this is needed for string comparison!!!

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

7. Shell Scripting
d argument is: birds Now we need to loop through each argument and decide what to do with it. A script like for i in $1 $2 $3 $4 ; do <statments> done doesn't give us much flexibilty. The <span>shift keyword is meant to make things easier. It shifts up all the arguments by one place so that $1 gets the value of $2 , $2 gets the value of $3 , and so on. ( != tests that the "$1" is no

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.