简体   繁体   中英

Linux: Illegal option read -a

I have found the answer for this question... Just want to provide some information for others, who met this problem too...

In my system, I got this problem because of I used the sh main.sh to process my shell script and ignore the difference between "Bash" and "Shell".

In order to solve this problem, you might try to change the mode into executable, by using chmod +x and using ./ to execute the program.

Good luck!

The error:

Illegal option read -a

was shown because you were trying to run it in a shell where the -a option for read isn't defined.

the command chmod +x script.sh has nothing to do with it. It just merely gives the script execution permission.

You were trying to run the command in Bourne shell by the command sh script.sh and Bourne shell read doesn't have the -a option for read. It's a Bash feature.

Running with ./ is not quite an answer. You could say at least : run it with path_to_the_script because not every time your script will end up in the current directory.

You can run it with bash main.sh instead of sh main.sh .

Easy way to get it over with is by bash script.sh it worked for me .

Also, when i was using read -d option permissions wasnt the issue but it was with shell so i used bash script.sh that did the trick

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM