bash scripting question

I am very much a beginner at shell scripting. As part of a script I'm working on, I want to create a directory on a remote ssh server, like so:ssh sshuser@$1 'mkdir ~/.ssh'Which is fine, except if the directory already exists, then I want to do something else.So instead of 'mkdir ~/.ssh', I want to do something like: if [ ! -d ~/.ssh ] ; then
mkdir ~/.ssh
#else do some shit here
fiwhich I have tested and it works.
But I want to fit it all in one line so I can do it in one ssh command. I have tried:andrew@fermion$ if [ ! -d ~/.ssh ] ; then ; mkdir ~/.ssh ; fi
bash: syntax error near unexpected token `;'doesn't work. I know you can probably come up with all kinds of different ways to do it, and I'd be interested to hear those, but just for curiosity's sake I especially want to know how to do an if-then on one line.

"then ;"

I know shit about shell scripting, but should you have a semicolon here?

That's it.andrew@fermion$ if [ ! -d .ssh ] ; then mkdir .ssh ; else echo poopy; fi
poopy

:)

isn't it fucked how that ALWAYS happens!

you're trying to learn a new language, you don't spot one syntax error, and someone who hasn't even learned the language but has a fresh view on things spots the problem.

I think someone did that to me on a problem with a Java program I was having when I was just learning that.

Fo sho. I just assumed there was no difference between the whitespace endline and the ';'.Now I have a slightly less embarassing one.I want to check if a certain directory is nonempty and then do a chmod 600 * if it is. if [ -e * ] ; then
chmod 600 *
fi
Which works if there's 0 or 1 files. But if there is more than one, then there's an error: bash: [: file1: binary operator expected Using the debug mode bash -x, I determined that she shell was interpreting the 'if' line as '[' -e file1 file2 ']' where file1 and file2 are the 2 files that are in the directory. This is how the * operator normally expands, but -e doesn't like that.So how do I check if a directory is not empty?

Found it on google.

if [ `ls | wc -l` -ne 0 ] ; then
chmod 600 *
fi