Thank you very much for your time and knowledge, the syntax error of the test statements were the problem. I'm just curious, what is the difference between:
and
I was taught to do the first when I first started to write scripting, and it's never given me any problems until this, which has now been fixed.
---------- Post updated at 03:43 AM ---------- Previous update was at 02:49 AM ----------
Also, using the "case" statement in this really made it way better. And I had never figured out how to properly use it until I saw what you wrote, so again, thank you. Showing me all of this has really improved my script and has given me more knowledge to equip me to write better scripts.
I hadn't noticed that the first line of your script contains a leading <space> character before the #!/bin/bash, so RudiC is probably correct in saying that that is why your script wasn't run using bash as its interpreter. Unless #!interpreter_path starts in column 1 on the 1st line in your file, that line is just a comment and has absolutely no effect on what interpreter will be used to run your script.
You haven't told us what operating system you're using, but it looks like the default shell on your is a Bourne shell or something like dash that doesn't include a lot of the bells and whistles provided by shells like bash and ksh that are extensions above and beyond what is required by the POSIX standards.
In POSIX-conforming shells the command:
is a synonym for the command:
and there is no specification of what:
does. The test and [ commands are utilities and they are often built-in into the shell as well as being available as stand-alone utilities. The [[ expression ]] is not a utility; it is a part of the syntax of those shells that provide this extension.
So, using [ "$var" = "string" ] is portable to a wide range of shells. And on shells that support [[ "$var" == "string" ]], it is often a little bit faster, often supports more operators than test, and has different requirements for when double-quotes are required and how shell variables are expanded.
I'm glad my sample case statement helped you figure out how it works. We're here to help you learn how to use the tools that are available to you on UNIX, Linux, and similar systems.
Hi,
I am a newbie here. Trying to find a way of writing a script to launch multiple terminal or console windows on solaris 9. I used to be able to do this using cmdtool on older versions of solaris and it was even possible to configure the size and screen position of the window and the title. ... (5 Replies)
I developed a script in Lingon (which is an automated script editor developed for OS X) that is used to automatically restart programs only if they crash. The script itself does just that, but I only want it to load if I'm going to use the specific application that it's designed to protect. In... (3 Replies)
I developed a script in Lingon (which is an automated script editor developed for OS X) that is used to automatically restart programs only if they crash. The script itself does just that, but I only want it to load if I'm going to use the specific application that it's designed to protect. In the... (2 Replies)
i wanted to execute some terminal commands on local linux, parse their output and display it to the user, i checked netcat source code but i couldnt understance it since im new to c (and linux at the same time).
so i was wondering if there is away to run an instance of terminal hidden, read and... (15 Replies)
Hello,
I have a PERL-TK based GUI from which I want to launch a command on an existing UNIX terminal (this is also the parent terminal for this perl based gui window). The command I want to launch is interactive (there is no intention to interact with that command from the same PERL gui i.e. no... (2 Replies)
After I installed OS X Lion I haven't been able to launch x11 remotely (using ssh) from Terminal.
It works fine locally, and also remotely directly from the Xterm.
I log in to the unix server at my university from the terminal like this:
ssh -l -X login@host.com
This used to launch... (1 Reply)
After installing centos iam not able to see the terminal icon in the applications menu to launch the command prompt in Centos.
However iam able to see the Open Terminal menu, when i right click and it is not working.
let me know what are the things i need to check.:b: (1 Reply)
So, I'm in a graphical terminal (xfce4-terminal) and I was wondering, would there be a way to type a command, and it run in a new terminal window?? An example would be like, say that I want to open a .txt file, but I want it in a different window, instead of the one that I'm currently using because... (1 Reply)
Hello All,
I have a text file containing output from a command that contains lots of escape/control characters that when viewed using vi or view, looks like jibberish. But when viewed using the cat command the output is formatted properly.
Is there any way to take the output from the cat... (7 Replies)