Skip to main content
3 events
when toggle format what by license comment
Nov 19, 2018 at 3:31 comment added Dimitry K .txt$ will match strings ending with txt regardless of the dot. Because grep takes regular expression as parameter. So files a.txt and aatxt and a-txt will all be matched by this expression. Correct expression should be ls | grep -v \\.txt$ | xargs --no-run-if-empty rm. For curious people: If you want to play around with the expression safely use this test expression ls | grep \\.txt$ | xargs --no-run-if-empty echo (note: there's no -v flag and rm=>echo). Note2: you may have noticed double backslash. One is for regex, another is for bash to escape slash.
Jun 5, 2013 at 19:48 history migrated from stackoverflow.com (revisions)
Jun 5, 2013 at 15:57 history answered rjv CC BY-SA 3.0