Re: Help with first bash script please

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Graham Cossey wrote:
I'm going nowhere at the moment with this VERY simple bash script, can
someone help please?

All I need to do is check the value of one of the command line parameters
and conditionally perform a task

1 #!/bin/bash
2 printf "Type = $6"
3 if [$6 == 'F']
4 then
5    Do the task
6 fi
7 Do other tasks

I keep getting:

Type = Q
line 3: [Q: Command not found

Add a space between the "[" and the "$6"; since "$6" is "Q", without the space you're trying to run a command "[Q", which doesn't exist. Also it's a good idea to put double quotes around parameters in case the parameter turns out to be empty (non-existent):


#!/bin/bash
echo "Type = $6"
if [ "$6" == 'F' ]; then
	Do the task
fi
Do other tasks

Also, does someone have a 'simple' bash scripting resource they could point
me to? I can find plenty of advanced scripting pages but founf nothing with
the above example that worked.

Try http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html

Paul.


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux