-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 :)

Dale
  • 1,903
  • 1
  • 16
  • 24
Erynne
  • 17
  • 3

1 Answers1

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.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • 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 – Erynne Dec 16 '13 at 08:06
  • 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"`.) – Jonathan Leffler Dec 16 '13 at 08:09
  • Syntax error near unexpected token 'else' – Erynne Dec 16 '13 at 08:12