Re: Help with first bash script please

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

 



On Thu, Oct 21, 2004 at 11:15:19AM -0400, Filippos Klironomos wrote:
> 
> > 3 if [$6 == 'F']
> 
> Leave a space always between the [ and ]
> 
> if [ $6 == "F" ]

One way to think about the opening [ is that it is a 
command. See "/usr/bin/[ ".

In olden days the program 'test' was linked to '['.
 
So if you translate [ to the test binary this line:

    if [$6 == 'F']

Becomes

    if /usr/bin/test$6 == 'F']
    if test$6 == 'F']

or perhaps 

    if /usr/bin/[$6 == 'F']

now with [ expressed with full path or full file name it might look as
if it needs the space.

With bash the command [ is built in.  We no longer execute the external
binary any more.  Regardless the man page for test aka [ has value.

I always thought that the link from "test" to "["  was clever.

The [[ ]] stuff does not feel so nifty but once the specific syntax
and requirement for spaces is nailed there is power.   
For fun compare and contrast [[ ... ]] with [ [ ...  ] ] ...  ;-).

So for extra credit what happens if you find a file $F=/usr/bin/[ and
then basename it and attempt to operate on it in a script ;-)

As for seeing spaces. in vim just search for them "/ ".  See also 
the vi/vim command 
   :set list 
to visualize tabs that are so key in "make" files (Makefile).

You can commonly cut and paste text from the web into a vim file and
use this trick to see spaces.  Maintaining tab characters is a problem
that no web or cut and paste trick seems to solve.

question for python guys... how do tabs and spaces translate where
indents are structure to the language.  (stty tab*).


-- 
	T o m  M i t c h e l l 
	May your cup runneth over with goodness and mercy
	and may your buffers never overflow.


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

  Powered by Linux