title: Having problems trying to figure out how to print variable values using this new bash-ism I'm exploring
body: <p>Good day all. I'm trying to learn if this is possible to do. I've been writing scripts in <code>#!/bin/sh</code> mode (interpreted with bash) for a while but am learning about bash-isms and am using <code>#!/bin/bash</code>. I am using <code>shellcheck</code> and <code>checkbashisms</code> to help me and I am wondering if what I hope to accomplish is easy. I'm using <code>stat -s</code> in a script which populates variables and I'm trying to cycle through them all to print to screen. Below is the minimal amount of code which demonstrates what I'm asking.</p>
  <p>I couldn't quite find a previously asked question which is similar. I have a feeling an array might be the way to accomplish what I'm hoping, but I thought I'd ask about this.</p>
  <pre><code>!/bin/bash
  
  T_FILE=/var/log/fsck_hfs.log
  
  s_vars=( st_dev=0\
           st_ino=0\
           st_mode=0\
           st_nlink=0\
           st_uid=0\
           st_gid=0\
           st_rdev=0\
           st_size=0\
           st_atime=0\
           st_mtime=0\
           st_ctime=0\
           st_birthtime=0\
           st_blksize=0\
           st_blocks=0\
           st_flags=0 )
  
  eval &quot;$(stat -s &quot;$T_FILE&quot;)&quot;
  
  printf &quot;\n\n%d\n\n&quot; &quot;$st_size&quot;
  
  for var in &quot;${s_vars[@]}&quot;; do
          printf &quot;%s\n&quot; &quot;$var&quot;
  done
  </code></pre>
  <p>As the more seasoned among you will probably notice straight away my <code>for</code> loop using that bash-ism will print the literals in s_var and I'd like them to print the values. I'd guess I'm going about this completely the wrong way, so any pointers would be appreciated. I've tried changing the <code>%s</code> format specifier in that <code>for</code> loop to a <code>%d</code> but it correctly points out <code>invalid number</code>.</p>
  <p>Here is a sample run of my code:</p>
  <pre><code>king:photosync hank$ ./stat.sh
  
  
  3614
  
  st_dev=0
  st_ino=0
  st_mode=0
  st_nlink=0
  st_uid=0
  st_gid=0
  st_rdev=0
  st_size=0
  st_atime=0
  st_mtime=0
  st_ctime=0
  st_birthtime=0
  st_blksize=0
  st_blocks=0
  st_flags=0
  king:photosync hank$
  </code></pre>