Hi,
Could you please explain to me what is the context of :-
nawk -v pat='^&*#' -f ah.awk myFile
Where do ah.awk comes? I assume "myFile" is the existing shell script.
And honeslty the code you shown me just stunned me. Correct me if I am wrong.
From my understanding,the first thing is to compare the blank spaces, and insert the patterns to pat array?
From the pat array which contain [%,$,`] , then you split the pat array to pat2 which holds the number of elements of pattern.
From these number of patterns, then what I could not really understood is:-
for(i=1; i <= patN; i++)
printf(" %d '%s' %s", gsub(patA[i], "", $0), patA[i], (i==patN) ? "\n" : "")
In this for loop, from 1 to number of lines in the file, you are trying to somehow check the pattern? But I do not really understand especially on
gsub(patA[i], "", $0), patA[i], (i==patN) ? "\n" : "") doing. Perhaps you could help to shed some light on this.
Sorry as I am quite new to the shell programming.
P/s: Is there any other ideas which we could use just awk and for loop without using the "ah.awk"?
Rgrds,
Jason