Bash patterns I use weekly
51–60 of 115 posts
Re: Bash patterns I use weekly
#52> git bisect is the "real" way to do this, but it's not something I've ever needed git bisect is great and worth trying; it does what you're doing in your bash loop, plus faster and with more capabilities such as logging, visualizing, skipping, etc. The syntax is: $ git bisect run [arguments] https://git-scm.com/docs/git-bisect
Yes, git bisect is the way to go: in addition to the stuff you mentioned, his method only dives into one parent branch of merge commits. git bisect handles that correctly. A gem of a tool, git bisect.
Re: Bash patterns I use weekly
#53Re: Bash patterns I use weekly
#54> 1. Find and replace a pattern in a codebase with capture groups > git grep -l pattern | xargs gsed -ri 's|pat(tern)|\1s are birds|g' Or, in IDEA, Ctrl-Shift-r, put "pat(tern)" in the first box and "$1s are birds" in the second box, Alt-a, boom. Infinitely easier to remember, and no chance of having to deal with any double escaping.
Re: Bash patterns I use weekly
#55Re: Bash patterns I use weekly
#56Re: Bash patterns I use weekly
#57 cat file
cat file | grep somethingRe: Bash patterns I use weekly
#58I want to like this, but the for loop is unnecessarily messy, and not correct. for route in foo bar baz do curl localhost:8080/$route done That's just begging go wonky. Should be stuff="foo bar baz" for route in $stuff; do echo curl localhost:8080/$route done Some might say that it's not absolutely necessary to abstract the array into a variable and that's true, but it sure does make edits a lot easier. And, the orig…
Even more correct would be to use an array: stuff=("foo foo" "bar" "baz") for route in "${stuff[@]}"; do curl localhost:8080/"$route" done
Thirteen Incorrect Ways and Two Awkward Ways to Use Arrays http://www.oilshell.org/blog/2016/11/06.html
In Oil the syntax is simplified to
const stuff = %("foo foo" bar baz)
for route in @stuff {
curl localhost:8080/$route # no quotes needed
}Re: Bash patterns I use weekly
#59Re: Bash patterns I use weekly
#60My daily bash pattern. cat file cat file | grep something