X${t} != X


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting X${t} != X
# 1  
Old 02-06-2006
X${t} != X

Hi all,
i have a variable T, its a path directory, (for instance my_main_dir/my_file.txt)

what does the following test condition mean?
if [X${T} != X]; then ...

i cannot find X declared anywhere else in the program. is X a reserved keyword in the IF test statements? Or can anyone explain the above test condition. Much appreciated.
# 2  
Old 02-06-2006
Its another way of testing for the contents of T.

From man ksh

Code:
               str                  str   has  non-zero  length.
                                    Note  that  there   is   the
                                    potential  for  problems  if
                                    str turns out to be an oper-
                                    ator (e.g., -r) - it is gen-
                                    erally better to use a  test
                                    like
                                                  [  X"str" != X
                                                  ]
                                           instead       (double
                                           quotes  are  used  in
                                           case   str   contains
                                           spaces  or file glob-
                                           ing characters).

# 3  
Old 02-06-2006
So X${T} != X tests if T is non zero.

Thanks vino.
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question