bash:在运行应用程序后,尝试在oneliner中继续运行命令时出错
我使用bash:在运行应用程序后,尝试在oneliner中继续运行命令时出错,bash,Bash,我使用findsearch results从命令行快速创建了一个audacious播放列表: mp3s=() ; while read -r -d $'\0'; do mp3s+=("$REPLY") ; done < <(find . -type f -iname "*every*.mp3" -print0) ; audacious "${mp3s[0]}" & ; for f in "${mp3s[@]:1}" ; do audtool --playlist-addurl
find
search results从命令行快速创建了一个audacious
播放列表:
mp3s=() ; while read -r -d $'\0'; do mp3s+=("$REPLY") ; done < <(find . -type f -iname "*every*.mp3" -print0) ; audacious "${mp3s[0]}" & ; for f in "${mp3s[@]:1}" ; do audtool --playlist-addurl "$f" ; done
如果我第一次运行,这是固定的:
mp3s=() ; while read -r -d $'\0'; do mp3s+=("$REPLY") ; done < <(find . -type f -iname "*every*.mp3" -print0) ; audacious "${mp3s[0]}"
有没有办法避免将此oneliner拆分为两个单独的命令,以便它们可以作为单个命令运行?在不知道为什么要在每个文件上运行单独的audtool实例的情况下(这似乎效率很低),我建议使用以下简单方法:
find . -type f -iname "*every*.mp3" -print0 | xargs -0 audacious
或者,如果一个命令行中容纳的文件太多:
find $PWD -type f -iname "*every*.mp3" -fprint temp.m3u ; audacious temp.m3u
查看并替换
&代码>由和@Cyrus省略
after&
创建仅包含数组的第一个元素的播放列表,抛出bac以下错误:`因此,&
之后仍然没有任何内容run@scriptz:吐回什么错误?(注意尖括号)。无论如何,您有一个竞态条件,因为不能保证在运行auditool
之前,auditional
将实际启动。顺便说一句,bash命令以&
或终止代码>,但不允许使用空命令,因此代码>无效,&
或&代码>(或者,就此而言,;&
)。
find . -type f -iname "*every*.mp3" -print0 | xargs -0 audacious
find $PWD -type f -iname "*every*.mp3" -fprint temp.m3u ; audacious temp.m3u