-2

How to write in Terminal RHEL 6.3 in a proper way?

If not exist LOCAL_WORKING_DIR LOCAL_EVENT_LOG_WORKING_DIR mkdir LOCAL_WORKING_DIR LOCAL_EVENT_LOG_WORKING_DIR ????

I have tried with this but seems didnt work My script :

if [! -f ] $LOCAL_WORKING_DIR $LOCAL_EVENT_LOG_WORKING_DIR
    mkdir $LOCAL_WORKING_DIR $LOCAL_EVENT_LOG_WORKING_DIR

In Windows we use WINSCP & 7zip right , is it okay to use Nautilus 3.10.1 & p7zip_9.20.1???

Do help me , please :)

2
  • Look at the related questions on the right. This is a FAQ. Commented Dec 16, 2013 at 7:49
  • 1
    Your question title should be a question rather than story time. :) Commented Feb 6, 2016 at 2:08

1 Answer 1

1

The simplest technique is to use mkdir -p which creates the directory — and any missing directories up the path — and does not fail if the directory already exists, so you can do it all at once with:

mkdir -p "$LOCAL_WORKING_DIR" "$LOCAL_EVENT_LOG_WORKING_DIR"

Note that the variables are enclosed in double quotes so that even if spaces (etc.) appear in the name, it will work sanely.

Sign up to request clarification or add additional context in comments.

3 Comments

Can u tell the error for me , if [ ! -d "$LOCAL_WORKING_DIR" ] then mkdir "$LOCAL_WORKING_DIR" cd "$LOCAL_WORKING_DIR" else cd"$LOCAL_WORKING_DIR" fi
Please don't put code in comments; you can't control the formatting. If you do, you have to be careful to make sure it will work despite the absence of formatting. What I can see has no semicolons, but semicolons would be necessary if it is all on one line. Edit your question. (The cd "$LOCAL_WORKING_DIR" should be after the if since you change to it regardless. The second one also needs a space between cd and "$LOCAL_WORKING_DIR".)
Syntax error near unexpected token 'else'

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.