Split the string to get only the first 5 characters

后端 未结 2 569
醉酒成梦
醉酒成梦 2021-01-29 12:34

I would like to go to the location /var/log/src/ap-kernelmodule-10.001-100

But looks like my code has to deal with ap-kernelmodule-10.002-100, ap-kernelmo

2条回答
  •  滥情空心
    2021-01-29 12:51

    You can't be in multiple cwds simultaneously. To run the command for each directory that matches the pattern, you can use 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
    

提交回复
热议问题