Last active
August 24, 2022 15:10
-
-
Save kyanny/d44a3fceeca22e76811744e8809e9602 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lcut() { | |
local input | |
if [ -p /dev/stdin ]; then | |
input=$(cat -) | |
else | |
input=$(cat $1) | |
shift | |
fi | |
echo $input | perl -slane '@pairs = /(\w+=?(?:"[^"]*"|[^\s]*))/g; | |
@keys = split /\s+/, $args; | |
foreach $key (@keys) { | |
foreach $pair (@pairs) { | |
($k, $v) = split /=/, $pair; | |
print $pair if $key eq $k; | |
} | |
}' -- -args="$*" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lfmt() { | |
local input | |
if [ -p /dev/stdin ]; then | |
input=$(cat -) | |
else | |
input=$(cat "$@") | |
fi | |
echo $input | perl -pe 's/(\w+=?(?:"[^"]*"|[^\s]*))/\n$1/g' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment