3
~/tomcat/apache-tomcat-7.0.90/bin$ sudo chmod 700/tomcat/apache-tomcat-7.0.90/bin/*.sh
chmod: missing operand after ‘700/tomcat/apache-tomcat-7.0.90/bin/*.sh’

I am not able to understand this error.

What should I do?

1
  • Use a space after the chmod command. And accept the answer that is given..
    – An0n
    Aug 21, 2018 at 22:13

3 Answers 3

6

There is a missing space character of chmod 700 in your question. Open the terminal and type:

sudo chmod 700 ~/tomcat/apache-tomcat-7.0.90/bin/*.sh  

The tilde character ( ~ ) in the above command indicates the current user's home directory. Check to make sure that a tomcat directory exists in your current user's home directory.

4

Commands in a shell are separated into "words" by special characters, most often spaces.

chmod expects at a minimum a string that defines the desired file mode (permission) change, and the name(s) of (a) file(s) to act on. chmod calls the file(s) to act on its "operand(s)". These two arguments, the mode and the operand, need to be separated by a space, which you missed out. Therefore, the single "word" after chmod is taken to be the desired mode (although it's not a valid one of course!) and the operand, the file to act on, is missing.

Note that if the filename contains spaces, you need to "quote" the space somehow to prevent it being interpreted as a separate word (and therefore a separate file).

The file whose permissions you want to change is apparently in your current working directory (your prompt shows this) so you don't need to enter the full path. You can just type ls to get the name of the script you want to run, then type

chmod 700 name.sh

or if you want to change the mode of every .sh file there you can use the glob as you tried

chmod 700 *.sh

By the way, if you only need to add execute permission for the owner of the file, you can use:

chmod u+x script.sh
0

I had a similar issue while writing the script and later noticed that awk output was displaying blank instead of file name.

Ex:

# tail -n 2 /tmp/watchfolder_logs|awk '{print $10}'

robin
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .