Ho do I find out the verion of the Kron shell on my client`s system ?
There is no one to ask. They are not knowledged enough (hard to believe but yes).
Also, on that AIX 4.2, I am trying to figure out how to do a grep using a search patter like below but does not seam to work. The '*' do not seam to be recognized.
"^*,3773,*,438,08..10..01,"
That would save me alot of grep from a grep from a grep ...
I am not completely sure what you are really seeking: is "Kron" a typo for "Cron" or for "Korn" (shell).
I suppose it is the latter, here is a procedure:
switch to vi editing mode. Enter at the command line "set -o vi"
press "ESC" to get into command mode
press <CTRL>-<V> to get the version. In my case (AIX 5.2, but yours should be no different) this gives "Version M-11/16/88f"
The asterisk "" is the metacharacter for "zero or more instances of the last regular expression". You have searched for "," which means "any number (including zero) of commas". If you want to search for "any string in any length" then use ".*" The dot "." means "any character" and the asterisk multiplies this to "any length", resulting in "any character n times, where n is any number including 0".
where the 'S' is a letter being D, A or S
where the 'xx' is either any text within commas or can be empty (meaning ,, )
where 999 is a command number
where 'yy/\mm/\dd' is a date with the '/\' characters
to my understanding, the amount of comma separated fields are constant but do not have to have data in them so they can be empty. Is it possible to do a grep search according to n-number of fields (comma separated) with some of those fields having specific values ?
my search criteria for the moment, is the command number and the date
As programing language, there only seams to be C, Bash and Korn. No Perl or anything else.
Yes, there is. We'll go through that one step at a time:
when the fields are comma-separated, then a single field would be: some (optional, the field could be empty) character(s) followed by a comma. A regular expression covering this would be:
[^,]*,
This regex would find any number of non-commas followed by a comma, in other words, one field. Lets assume now that you want to search for a specific content of the 18th field. You would have to look for 17 repetitions of this pattern followed by some value. Fortunately there is a "multiplicator" device for such occasions in regex:
\([^,]*,\)\{17\}search,
This would search for 17 repetitions of "[^,]*," (the "\(" and "\)" are grouping characters, the "\{...\}" is said repetition counter - sort-of "parameterized asterisk"), followed by "search" as the text to search for in the 18th field.
You should no be able to construct your own regexp, based on this.
No. As i have elaborated on above the "[^,]" means "anything, but a comma", therefore a comma is the last thing that could be matched by it. Additionally the "" means "zero or more occurrences". For example "abc" would be matched not only by "abc" and "abbbc" but also by "ac". It would not be matched by "adc" though.
hm, that is quite astonishing. I tried exactly your data and command and it is working (here on cygwin, but that shouldn't matter):
bakunin@cygwin ~/tmp$ cat test.asc
x(xx,x,x,,,x,x,9999,,x,,,xx,,,xxxx,,,,,,,,,,,,,,,,,,999,
x(xx,x,x,,,x,x,8888,,x,,,xx,,,xxxx,,,,,,,,,,,,,,,,,,999,
bakunin@cygwin ~/tmp$ grep "^\([^,]*,\)\{7\}8888" test.asc
x(xx,x,x,,,x,x,8888,,x,,,xx,,,xxxx,,,,,,,,,,,,,,,,,,999,
bakunin@cygwin ~/tmp$ grep "^\([^,]*,\)\{7\}9999" test.asc
x(xx,x,x,,,x,x,9999,,x,,,xx,,,xxxx,,,,,,,,,,,,,,,,,,999,
bakunin@cygwin ~/tmp$ grep "^\([^,]*,\)\{33\}999" test.asc
x(xx,x,x,,,x,x,9999,,x,,,xx,,,xxxx,,,,,,,,,,,,,,,,,,999,
x(xx,x,x,,,x,x,8888,,x,,,xx,,,xxxx,,,,,,,,,,,,,,,,,,999,
bakunin@cygwin ~/tmp$ grep --version
grep (GNU grep) 2.5.1
Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
by the way: i have edited the thread title so that it can easier be searched for. I hope you don't mind.
bakunin
Beside the AIX grep there is a second supported grep version from the IBM Linux Toolbox. I would not be suprised if those two grep programms differ just as many others like "find" "make" etc. do
I could test with other versions of AIX, but i suppose there would be no difference. Is in your data any non-printing character or something like that? have you tried the command outside of the script? Maybe its one of these "obvious" yet hard to find things one tends to think about always last.