I would like to go to the location /var/log/src/ap-kernelmodule-10.001-100
/var/log/src/ap-kernelmodule-10.001-100
But looks like my code has to deal with ap-kernelmodule-10.002-100, ap-kernelmo
You can't be in multiple cwds simultaneously. To run the command for each directory that matches the pattern, you can use Dir#glob:
cwd
Dir#glob
Dir.glob('/var/cache/acpchef/src/ap-kernelmodule-10*').each do |cwd| Mixlib::ShellOut.new("command run here", cwd: cwd).run_command end