Hi everybody,
I just start my learning about Linux.
So, if you can help me, it would be very good !
I have already find the possibility to find the position of a character regular expression in a line with the help of awk :
test.txt is : AAAAAGHIJKLAjKMEFJKLjklABCDJkLEFGHIJKL
My script is like this :
awk -f findstring.awk test.txt > testreturn.txt
And my findstring.awk is like this :
BEGIN{ SLENGTH = 3 }
{
string = "jkl"
skipped = 0
starts = ""
while ( SSTART = index($0,string )) {
starts = starts (starts?" ":"") (skipped + SSTART)
$0 = substr($0,SSTART + SLENGTH)
skipped += (SSTART + SLENGTH - 1)
}
}
starts { print starts }
The command returns 21, as expected (beginning of the string "jkl").
With string = "JKL", the command returns 9 18 36, as expected also.
But, I'm not able to apply the same system with the same .awk to find not only "jkl" regular expression, but also in the same time "JKL" and "JkL".
By extension, the goal is to find a regular expression without case sensitivity, and also able to find "jKM" (with a variability at one or more positions in this same regular expression).
I really want to thank you before your answers.
Best.