0

Unix question

I need to write a script that will accept any number from the command line parameters. then using a while loop process through all of tgen and display each parameter on a different line on the screen.

8th Jun 2018, 7:56 PM
Julie Ann
Julie Ann - avatar
5 ответов
+ 5
read command is not for getting parameters. it is for for getting some input data while script is running: $cat read.sh #!/bin/sh read -p "What is your name?" name echo "Hello, $name." $chmod 755 read.sh $./read.sh What is your name?John Hello, John. $
12th Jun 2018, 7:48 PM
Dmitriy
Dmitriy - avatar
+ 3
$ cat param.sh #!/bin/bash #while parameter's number greate then 0 while [ $# -gt 0 ] do #print the first parameter echo $1 #remove the first & shift others so that 2-nd 3-rd 4-th... will 1-st 2-nd 3-rd ... shift done $chmod 755 param.sh $./param.sh q we rty uiop q we rty uiop $
12th Jun 2018, 7:40 PM
Dmitriy
Dmitriy - avatar
+ 3
$ cat param2.sh #!/bin/bash while [ $# -gt 0 ]; do echo $1; shift;done $chmod 755 param2.sh $./param2.sh q we rty uiop q we rty uiop $
12th Jun 2018, 7:41 PM
Dmitriy
Dmitriy - avatar
+ 2
#!/bin/bash for i in $@;do echo "parameter..."$i;done
11th Jun 2018, 2:13 AM
Dmitriy
Dmitriy - avatar
0
I cannot use the read command
8th Jun 2018, 7:56 PM
Julie Ann
Julie Ann - avatar