[RndTbl] shell quoting inside $( )?
Scott Toderash
scott at 100percent.ninja
Sun Feb 26 19:09:38 CST 2023
Not sure if this is it, but backticks.
eg.
EXPD=$(date -d"$(`$(openssl x509 -noout -text -in "$1")` | sed -n
's/^.*Not After : //p')" +%Y%b%d)
On 2023-02-26 18:07, Adam Thompson wrote:
> I’m trying to figure out if there’s a way to do this more
> compactly (for reasons…):
>
> T=$(openssl x509 -noout -text -in "$1")
>
> EXPD=$(date -d"$(echo "$T" | sed -n 's/^.*Not After : //p')" +%Y%b%d)
>
> SUBJ=$(echo "$T" | sed -n 's/^.*Subject: .*CN = //p')
>
> I am having two issues:
>
> * Bash doesn’t happily let me embed double quotes inside a
> subshell inside a subshell inside double-quotes. All of the
> double-quotes are required, AFAICT. So doing
> X=$(…”$(…”xxx”)”) just doesn’t work because bash
> doesn’t parse nested double-quotes. But both the inner var and the
> result can and will have spaces in them.
> * I can’t remember how in shell (bash, in this case) how to
> bifurcate stdout and have it run to two pipelines. I figure echo is a
> builtin, so should at least be lighter than re-running the monstrosity
> that is openssl over and over. I have a vague recollection that this
> is harder than it sounds, and may not be worth it…
>
> Any suggestions on how to solve either issue? I’m sure I’ve just
> forgotten some obvious technique, hopefully someone can jog my mind.
>
> -Adam
> _______________________________________________
> Roundtable mailing list
> Roundtable at muug.ca
> https://muug.ca/mailman/listinfo/roundtable
More information about the Roundtable
mailing list