sift
sift copied to clipboard
Feature Request: Path Numeric Range
Something GREP has been missing, are taking number ranges as file names. Log files more often than not have a date in them, it would be nice to be able to use something like: ./sift -z "string" --path '/log/file/path/http_log_.2016.02.(10|11|12|13).log.gz to search in the 10th, through the 13th log files. I've tried all kinds of escapes and such, can't seem to make that work. I tried a range, but I know it's not just sticking to 10-13. ./sift -z "string" --path '/log/file/path/http_log.2016.02.[10-13]_.log.gz <--incorrect perhaps is a failing of bash?
The --path option only works as a filter on the given search targets. You did not specify a search target, so sift searches in the current directory by default and then only selects files matching the given path regex, so in the end no files are searched.
Your parameter used for --path looks correct though. This a short test I did, please test if it works for you when you use sift this way:
$ find /tmp/logs/
/tmp/logs/
/tmp/logs/test15.log.gz
/tmp/logs/test14.log.gz
/tmp/logs/test09.log.gz
/tmp/logs/test13.log.gz
/tmp/logs/test12.log.gz
/tmp/logs/test11.log.gz
/tmp/logs/test10.log.gz
$ sift -z test /tmp/logs/ --path '/tmp/logs/test(10|11|12|13).log.gz'
/tmp/logs/test10.log.gz:test10
/tmp/logs/test11.log.gz:test11
/tmp/logs/test13.log.gz:test13
/tmp/logs/test12.log.gz:test12
# you could omit the path in the pattern for the path option:
$ sift -z test /tmp/logs/ --path 'test(10|11|12|13).log.gz'
I get unexpected token for the opening paren. Escaping does not appear to work. I've tried other shell's but it only changes the error message. I am also dealing with numbered folder names as well as odd filenames. /www/logs/mpri20 through 29 with hundreds of file names like http_log.123456.2016.02.11.2468.log.gz I can grep like so: grep something /www/logs/mpri2_/http_log..2016.02.11..log.gz But I'd like to narrow it down to (or something similar) /www/logs/mpri2(1|3|5)/http_log._.2016.02.11.*.log.gz (searching folders 21, 23 and 25)
Star/wildcards got removed (stupid MD) grep something /www/logs/mpri2_STAR_/http_log.STAR.2016.02.11.STAR.log.gz
It is difficult to solve this without some test data, but please try the following:
sift -z 'PATTERN' /www/logs --path 'mpri2(1|3|5)/http_log.*2016.02.11.*log.gz'
That works really well actually! I tried things similar but what I did was not working, thanks a lot for addressing my question.