$ jo foo=bar | parallel 'echo {[.foo]}'
bar
$ echo -e "$(jo foo=bar)\t$(jo bad=baz)" | parallel --colsep=\t 'echo {1[.foo]} blah {2[.bad]}'
bar blah baz
Last active
November 3, 2023 21:00
-
-
Save vergenzt/864010adbac64def312190d85607109b to your computer and use it in GitHub Desktop.
GNU parallel - easy JSON processing placeholder via jq expression
This file contains 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
--rpl '{[(.*?)]} uq(); $Global::use{"IPC::Open2"} ||= eval "use IPC::Open2; 1;"; my $jq = open2(my $jq_out, my $jq_in, "jq", "-Rrc", "[ try(fromjson) // . | $$1 | tostring ] | \@sh") or die "Could not open pipe to jq!"; print $jq_in $_; close $jq_in; $_ = do { local $/; <$jq_out> }; chomp; waitpid $jq, 0; $? && die' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment