Skip to main content
12 events
when toggle format what by license comment
Oct 13, 2021 at 21:31 comment added cas @schrodigerscatcuriosity you're right. i keep forgetting that because i'm used to using -m1 when i want to match.
Oct 13, 2021 at 10:24 comment added schrodingerscatcuriosity @cas according to the (GNU) manual both -l and -L stop scanning after the first match, so -m1 wouldn't be needed.
Oct 13, 2021 at 10:19 comment added schrodingerscatcuriosity @ilkkachu thanks! I edited the answer with the GNU -L option.
Oct 13, 2021 at 10:17 history undeleted schrodingerscatcuriosity
Oct 13, 2021 at 10:17 history edited schrodingerscatcuriosity CC BY-SA 4.0
added 401 characters in body
Oct 13, 2021 at 9:58 history deleted schrodingerscatcuriosity via Vote
Oct 13, 2021 at 9:55 comment added ilkkachu hum, is this right? If I've understood correctly, -v looks for lines not matching the pattern, and then -l prints files where any line meets the condition. And with -v, that's files that have at least one line that does not match the pattern. E.g. printf '%s\n' 'foo' '::' > test.txt and the grep would match test.txt. You'd need -L/--files-without-match from GNU grep. Or a shell loop around grep -q, inverting the sense. Or -z and the assumption that the files don't have NULs, and hence just one NUL-terminated "line".
Oct 13, 2021 at 9:38 comment added schrodingerscatcuriosity @cas added your suggestions (and correction) to the answer, thanks!
Oct 13, 2021 at 9:36 history edited schrodingerscatcuriosity CC BY-SA 4.0
added 239 characters in body
Oct 13, 2021 at 1:53 history edited schrodingerscatcuriosity CC BY-SA 4.0
added 2 characters in body
Oct 13, 2021 at 1:02 comment added cas +1, much better than my idea (which was to use perl -0). You could speed that up with -m 1 to skip to the next file on the first line in that matches the unwanted pattern - it would skip scripts, for example, after the first line (#!). Also, probably should be a bracket expression [#></:] otherwise grep will try to match that exact sequence of characters instead of any one of them. And maybe use -Z for NUL-separated output if the script is going to do anything with the files other than just list them.
Oct 12, 2021 at 22:24 history answered schrodingerscatcuriosity CC BY-SA 4.0