3 ms·
I do like how it's a bit more semantic but find/replace for all instances of files that contain a search term in any .sh is like perl -p -i -e 's/term/replac
by jamal-kumar 4y ago
I do like how it's a bit more semantic but find/replace for all instances of files that contain a search term in any .sh is like
perl -p -i -e 's/term/replacement/g' | $(grep -rl term)
It's unbelievably fast and handy when you have multiple directories to recurse through or or tons of files. Anyone can remember that after using it like twice. Powershell requires like five lines of code just to get that done as you demonstrated. That's not feature parity at all. I also strongly feel it's way more readable than your example.
- mgdlbp 4y agoOops, the PS ? and : actually need to be on the same line. Whiteboard fail. Likewise there shouldn't be a pipe before grep, right? So, perl -pi -e 's/term/replacement/g' $(grep -rl --include=\*.sh term) Apples-to-apples, the date conversion with perl is, perl -pi -e 'use Time::Piece; s/\b(\w+ \d\d?, \d{4})\b/ eval{Time::Piece->strptime($1, "%B %d, %Y")->strftime("%Y-%m-%d")} or $1/eg' \ $(grep -ilE '(ERROR|WARNING)' *.sh) and the simple replace with PS is ls *.sh -r -File | %{($_|gc) -replace 'term','replacement' | Out-File $_} Not Perl terseness, but not 5 lines either (maybe in Visual Basic).