# # grep 1.0 -- addes [e]grep support to the client, neat # Author -- wd@anduril.org White_Dragon Chip Norkus # Any deviation from the original is Jeremy Nelson's fault. # # Contributed to the EPIC project by Phoengold, on Fri, 14 Apr 2000. # # Usage: /grep [-w #] # /egrep [-w #] # Performs a text search on the lastlog of the current/specified window # # At the most basic level, /grep searches the lastlog of your current window # for the specified text. with the -w option you can specify the window # whose lastlog you want to use. A regular expression of any sort can be # used, as well. # alias grep { ^local win,exp,re,i,x,l,s.,l. if (![$0]) { echo Usage: /grep [-w #] return } @ win = 1 if ([$0] == [-w]) { if (![$2]) { return } @ win = [$1] @ exp = [$2-] }{ @ exp = [$*] } if (!winlevel($win)) { assign -win } @ re = regcomp($exp) ### grep here, and save the lines @ i = getset(LASTLOG) @ x = 0 while (i) { l = line($i $win) if (!regexec($re $l)) { @ s[$x] = l @ l[$x] = i @ x++ } @ i-- } @ regfree($re) echo ------------------ Results of grep: ---------------------- @ i = 0 while (i < x) { xecho -nolog $[4]l[$i]: $s[$i] @ i++ } echo ------------------------ End ----------------------------- } #WhiteDragon'Y2K .