Bash script: Scanning for text
Hi all. Just looking for some clues to get started.
I want to use bash to scan a text file for a keyword, look at the next character and then increment a counter depending on the character. So it would look for the word START and if the next character in the file is not E from (END) then a counter would be incremented. Any ideas? I'm thinking it would involve awk and sed. ie. Code:
START |
Code:
count=$(awk '/START/{start=NR};/END/{if (NR > start + 1) count++}END{print count}' file) |
...and without awk:
Code:
COUNTER=0 |
... and since you asked for sed:
Code:
for i in `sed ':t; /START/,/END/ { /END/!{ $!{ N; bt; } }; s/\n//g; s/START//; s/END//; /./!d; }' sometextfile` ; do |
All times are GMT -5. The time now is 05:06 AM. |