Thursday, 15 March 2012

Bash test if #- in string but NOT #-# or #-#-# -


I have a file and 5 different references to that place, like;

  search | Content # - | Some HTML # 9-22 Names Pat = # - #. Some.htm # 1-some.htm # 3 named pat2 = # - # - #. # Html # 21-some HTML # -some.htm # 4; pat3 =; | Some HTML # 6-Some HTML # 13; Some HTML # 22-23 names pat4 = else | Some HTML # #  

There are some references from these 550 in a CSV data file.

The problem I have is the reference to see how to test the variable that includes the listed search columns listed above. I know that there are special characters in it, I have not got any reference to do a search online in a test.

  pat = [# -] if [[$ ALIYAH == $ pat]]; "SHAR1 =" $ (GUN "$ ALIYAH" | awk -F \ # '{print $ 1}') "START1 =" $ (echo "$ ALIYAH" | awk -F \ # '{print $ 2}' | Awk - F - '{print $ 1}') "END1 =" $ (echo "$ ALIYAH" | awk -F - '{print $ 2}') "return  

thanks

So I have made the changes below but there is no happiness.The test does not match and therefore it is falling through default and should not be processed as much as $ {Arr [2 ] Debug output for ALIYAH

  +: 2:11} '' + = '[# -]' + [[Some HTML # 11-38 == \ [\ # \ - \]]] ++ echo Some HTML # 11-38 ++ AcaxA-F '#' '{Print $ 1}' + Head # 10 = Some HTML # This is a fall, should fill  

After some more searches, I tried

  if [["$ ALIYAH" = ~ [# -]]]   

and

As I was afraid that it is also positively testing for Patterns 2 and 3

Put quotation marks around the variable name:

  If [["$ ALIYAH" == "$ pat"]]; Then ... etc ...  

No comments:

Post a Comment