March 19, 2011

Reading script lines in a script file

I am reading the rc.modules script file in slackware trying to understand what this file is actually doing. In the rc.modules file, the first line reads

if { -x /usr/bin/find -a -e /lib/modules/$RELEASE/modules.dep \..

What does "-x" mean? Is this referring to the command line?

try here http://linux.die.net there is more talk about linux script

try here http://linux.die.net

there is more talk about linux script

Like  (0 likes)

Thanks, that was helpful.

Thanks, that was helpful.

Like  (0 likes)

Jabir is correct. ...

Jabir is correct.

To understand the flags using in the statements of a shell script you should read the bash manual, you can find an online version at http://linux.die.net/man/1/bash and search for the sequence that you are questioning.

Like  (0 likes)

Are you sure it's a curly brace '{', and not a square bracket '['? The square...

Are you sure it's a curly brace '{', and not a square bracket '['? The square bracket is just an alternative (and quite common) syntax for invoking the command test (1). According to the man page, '-x' checks if a file is executable, '-a' means 'and', '-e' checks if a file exists.

So in other words, if the command was actually something like
if [ -x /usr/bin/find -a -e /lib/modules/$RELEASE/modules.dep ]
then it would be equivalent to the pseudocode
if ( ( /usr/bin/find is executable) and ( /lib/modules/$RELEASE/modules.dep exists ) )

Like  (0 likes)
Click Here!