Hi,
I read something like "\mkdir ${RESULT_DIR}". Just curious about why "\" is added before the command? Thanks for help!

It typically represents a new line. Try it at a command line... type in say: mkdir \
your prompt will probably change to >, which means the command is not complete yet, and requests more info. I don't know the context or the script, so it makes it a little more difficult to explain.

I think it is not a newline. Here goes the context:

    if [[ -d ${RESULT_DIR} ]]; then
        echo "Directory ${RESULT_DIR} already exists."
        exit 1
    fi

    \mkdir ${RESULT_DIR}

    if [[ ! -d ${RESULT_DIR} ]]; then
        echo "Can not find ${RESULT_DIR}"
        exit 1
    fi

Without the backslash, the shell checks to see if there is an alias for the command. If so, it uses it.

With the backslash, the shell skips this check and runs the first version of the command that it finds in $PATH.

N

commented: Fantastic Contribution +9
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.