Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Bash command in a variable without executing

I have two commands which I want to close in variables:

val=`awk -F "\"" '{print $2}' ~/.cache/wal/colors-wal-dwm.h | sed -n -e 1,3p -e 5,7p`
dummy=`printf "dwm.normfgcolor:\ndwm.normbgcolor:\ndwm.normbordercolor:\ndwm.selfgcolor:\ndwm.selbgcolor:\ndwm.selbordercolor:")`

They basically print some stuff. I want to merge the output with paste command (this doesn’t work):

paste <($dummy) <($val)

I wanted to avoid temp files but at this point I’m out of ideas. Thanks in advance.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

$dummy

Is a variable, not a command to execute. echo is a command. printf is another command.

paste <(echo "$dummy") <(echo "$val")

Do not use backticks – $(..) instead. Check your scripts with shellcheck. You code is somewhat unreadable to me… if you don’t care about variables, just don’t use them.

awk -F '"' '{print $2}' ~/.cache/wal/colors-wal-dwm.h |
sed -n -e 1,3p -e 5,7p |
paste <(
     printf "dwm.%s:\n" \
        "normfgcolor" \
        "normbgcolor" \
        "normbordercolor" \
        "selfgcolor" \
        "selbgcolor" \
        "selbordercolor"
  ) -
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading