I have a Bash script that builds a string to run as a command
Script:
#! /bin/bash
matchdir=\"/home/joao/robocup/runner_workdir/mat
For me echo XYZ_20200824.zip | grep -Eo '[[:digit:]]{4}[[:digit:]]{2}[[:digit:]]{2}'
was working fine but unable to store output of command into variable.
I had same issue I tried eval
but didn't got output.
Here is answer for my problem:
cmd=$(echo XYZ_20200824.zip | grep -Eo '[[:digit:]]{4}[[:digit:]]{2}[[:digit:]]{2}')
echo $cmd
My output is now 20200824
I usually place commands in parentheses $(commandStr)
, if that doesn't help I find bash debug mode great, run the script as bash -x script