3 ms·
Oops, 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/re
by mgdlbp 4y ago
Oops, 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).