comment
How to use jq to convert an bash array in command line to json array?
note: you might want
-- after --args/--jsonargs and before "${mylist[@]}" because my input had -c in it which jq read as an control argument comment
How to use jq to convert an bash array in command line to json array?
this works ok for me but how do i adjust the formatting of the outputted JSON? i prefer minimal prettyprinting (spaces after elements except begin/end of array/object):
[1, 2, 3, 4, 5, "b"] comment
How to use jq to convert an bash array in command line to json array?
@muru for those wondering
-n, from manpage: "--null-input/-n: Don't read any input at all! Instead, the filter is run once using null as the input. This is useful when using jq as a simple calculator or to construct JSON data from scratch." comment
grep use -v on one regexp and disable for another
@NasirRiley i have GNU awk (says
mawk in manpages), but it seems to use extended regex? i couldn't find a way to disable that feature and just use basic regex. an alternative would be, if i did use that, what special chars do i escape to interpret as literal? (i can do this before awk, probably using sed). i tried looking them up but failed to find a specific answer comment
grep use -v on one regexp and disable for another
@KamilMaciorowski not quite, as my actual use case involves large and complicated strings it needs to not match (
-v), and a single character it needs to match. grep -v '^complicatedRegex$\|[^l]' and grep -v '^complicatedRegex$\|.*[^l].*' didn't work as expected Loading…
revised
Get GNU tar PID inside of --to-command
formatting
Loading…
comment
Get GNU tar PID inside of --to-command
$PPID works really well, strange that it doesn't show up in printenv comment
Get GNU tar PID inside of --to-command
I have
alias tar='POSIXLY_CORRECT=1 tar' in my .bashrc, is that likely to interfere? comment
Get GNU tar PID inside of --to-command
Could you please explain what
ps is doing here? ____ This appears to work as expected, but I am now curious; how come the PID printed with ps and from the shell with & suffix do not match my subsequent echo $!? comment
Get GNU tar PID inside of --to-command
@muru I just ran it as
--to-command=printenv and --to-command='sh -c printenv', both with echo $! right afterwards, and could not find the mentioned PID anywhere in printenv's output Loading…
comment
Verify sha256sums of files inside tarball using hashfile
This answers here is really close, only it creates hashes of files in tarball instead of verifying hashes from a separate list: serverfault.com/questions/1000381/hash-files-in-tar-file
revised
Loading…
comment
Verify sha256sums of files inside tarball using hashfile
My GNU tar version is 1.34, GNU sha256sum (coreutils) version is 9.1, OS is Debian bookworm
Loading…
comment
How to list files and directories with directories first
i wish i could upvote this twice for your making awareness of troublesome newlines etc in filenames. programmers shouldn't assume alll the user's filenames are sane! you never know when that curveball will appear :) thanks
awarded