Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
l0b0
on Aug 21, 2021
|
parent
|
context
|
favorite
| on:
An Opinionated Guide to Xargs
I scanned until I saw `ls | egrep '.*_test\.(py|cc)' | xargs -d $'\n' -- rm`, and then stopped. This is a terrible idea[1][2].
[1]
https://mywiki.wooledge.org/ParsingLs
[2]
https://unix.stackexchange.com/q/128985/3645
tyingq
on Aug 21, 2021
[–]
I'm surprised the links don't mention find. The -print0 flag makes it safe for crazy filenames, which pairs with the xargs -0 flag, or the perl -0 flag, etc. And you have -maxdepth if you don't want it to trawl.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
[1] https://mywiki.wooledge.org/ParsingLs
[2] https://unix.stackexchange.com/q/128985/3645