An alternative way is to use /filter twice: one pass to grab the matching lines and another to remove matching lines from the file (using the -x switch), so that the search for the next string is done on the remaining lines (excluding the previous matches). Here's an example:
alias multsearch {
write -c outfile.txt
window -h @ms1
loadbuf @ms1 infile.txt
tokenize 124 $1-
multsearch2 $*
close -@ @ms1
}
alias multsearch2 {
filter -wf @ms1 outfile.txt * $+ $1-*
filter -wwcx @ms1 @ms1 $1- * $+ $1-*
}
Change infile.txt and outfile.txt accordingly and test with
/multsearch string 1|string 2|string 3|string 4Note that the matches in outfile.txt are ordered according to which string matched them (and
then according to their position in infile.txt), unlike Horstl's methods, so use whichever method suits you.