example bash file:
save the following in a file called print.sh
#!/bin/bash
echo “$@”
and then :
chmod +x print.sh
./print.sh hello world
Note that, all the parameters you pass to print.sh will be passed to echo, this because of “$@”
example bash file:
save the following in a file called print.sh
#!/bin/bash
echo “$@”
and then :
chmod +x print.sh
./print.sh hello world
Note that, all the parameters you pass to print.sh will be passed to echo, this because of “$@”
One question: Do you mean that in the above example you passed 2 parameters "hello" and "world"?
LikeLike
Yes.Try this #!/bin/bashecho "$1"and then:./print.sh hello worldThe result will be just "hello"
LikeLike