如果命令在字符串中,我如何在bash脚本中的后台执行shell命令?
例如:
#!/bin/bash cmd="nohup mycommand"; other_cmd="nohup othercommand"; "$cmd &"; "$othercmd &";
这不行 – 我该怎么办?
留下报价
原文链接:https://www.f2er.com/bash/388761.html$cmd & $othercmd &
例如:
nicholas@nick-win7 /tmp $ cat test #!/bin/bash cmd="ls -la" $cmd & nicholas@nick-win7 /tmp $ ./test nicholas@nick-win7 /tmp $ total 6 drwxrwxrwt+ 1 nicholas root 0 2010-09-10 20:44 . drwxr-xr-x+ 1 nicholas root 4096 2010-09-10 14:40 .. -rwxrwxrwx 1 nicholas None 35 2010-09-10 20:44 test -rwxr-xr-x 1 nicholas None 41 2010-09-10 20:43 test~