(1) I have read in "several" books on the Korn shell, that the Korn shell does "pattern matching". I had presumed that meant that it matches on ANY text-file-content which is read by a Korn shell program. (Similar to the patterm matching done with a perl program.)
(2) However, when trying to do 'patterm matching" inside a "Korn shell" program which is reading a text-file, I have NOT been able to devise any "if statements" that will successfully "match" (uing regular expressions"
any of the text phrases in the test file.
(3) Perhaps my "programing statement" are NOT CORRECT for pattern matching in Korn shell? OR, mayber korn shell does pattern matching just on FILENAMES, but NOT on text it reads form a text file.
(4) Program:
1 #!/bin/ksh
2 # program ksh_pattern_matching.ksh
3
4
5 while readle read -u3 g1
6 do
7
8 if [[ $g1 = "[0-9]{1}the" ]]
9 then
10 echo "Found one: \$g1 = $g1"
11 fi
12
13
14 done 3< $1
# looking to find strings like "456the", or
# "789the", when these kind of strings are
# EMBEDDED in a text file: $1.
(5) I dont get error messages with the above program, but I don't "echo" any output either. Is there somethinhg wrong with the program, or is that Korn shell just DOESN'T do this 'textual" pattern matching?
(6) Maybe I just have to use perl, instead, which does this klind of thing VERY WELL!
thanx in advance.
End-of-memo: Best to you..
from ernieah.
(2) However, when trying to do 'patterm matching" inside a "Korn shell" program which is reading a text-file, I have NOT been able to devise any "if statements" that will successfully "match" (uing regular expressions"
(3) Perhaps my "programing statement" are NOT CORRECT for pattern matching in Korn shell? OR, mayber korn shell does pattern matching just on FILENAMES, but NOT on text it reads form a text file.
(4) Program:
1 #!/bin/ksh
2 # program ksh_pattern_matching.ksh
3
4
5 while readle read -u3 g1
6 do
7
8 if [[ $g1 = "[0-9]{1}the" ]]
9 then
10 echo "Found one: \$g1 = $g1"
11 fi
12
13
14 done 3< $1
# looking to find strings like "456the", or
# "789the", when these kind of strings are
# EMBEDDED in a text file: $1.
(5) I dont get error messages with the above program, but I don't "echo" any output either. Is there somethinhg wrong with the program, or is that Korn shell just DOESN'T do this 'textual" pattern matching?
(6) Maybe I just have to use perl, instead, which does this klind of thing VERY WELL!
thanx in advance.
End-of-memo: Best to you..
from ernieah.