[sclug] Bash scripting help needed

Keith Edmunds kae at midnighthax.com
Tue Apr 21 20:39:42 UTC 2009


On Tue, 21 Apr 2009 20:30:30 +0100, haughtonomous at googlemail.com said:

> if ["$1" -eq ""]; then
> echo "Use: command codectype outputfilename"
> exit
> fi
> 
> if ["$2" -eq ""]; then
> echo "Use: command codectype outputfilename"
> exit
> fi

You don't need the first test (for $1) above - if it is null then $2 will
be too; as others have pointed out, you need spaces around the "[" and "]".

> `shnjoin -o $1 $fileList`

You don't need backticks around this (and, when you do need backticks, the
construction "$( ... )" is easier to read and can have more $(..) embedded
in it).

> shnjoin: warning: cannot open non-existent file: ["01.flac"]
> shnjoin: error: could not open file: ["01.flac"]

> 2. Why the "cannot open non-existent file" warnings when the files do
> indeed exist in the current directory (from where I launch the command),
> which by the way is in my home folder?

Because you probably don't have files named ["01.flac"], although you may
have one named 01.flac - this again is a symptom of the lack of spaces
around the brackets.

hth



More information about the Sclug mailing list