gpt4 book ai didi

linux - 使用 Xargs 等待回车键

转载 作者:太空宇宙 更新时间:2023-11-04 03:38:00 24 4
gpt4 key购买 nike

所以,我有一个文件列表,我想用它来生成一组新的文件组。我想同时打开这些组(多个文件)。编辑它们。然后返回终端,按 Enter 键,然后打开下一组文件。

我已经让它工作了,但我正在使用一个临时文件来这样做

cat failingAll | awk '{print $2}' | xargs -I {} -L 1 sh -c "find {} | grep xml | xargs echo;" | perl -pe "s/^(.*)$/open \1;read;/g" > command.sh ; sh command.sh

仅使用 xargs 可以做到这一点吗?真的,我的意思是没有临时文件。我试过这个

cat failingAll | awk '{print $2}' | xargs -I {} -L 1 sh -c "find {} | grep xml | xargs open ; read;"

但它不会在组之间暂停,它只是一次打开所有组(并导致我的 xml 编辑器崩溃。)

最佳答案

尝试这样的操作,并在编辑完每组文件后退出编辑器?

while IFS= read -r dir; do
files=()
while IFS= read -r -d '' xmlfile; do
files+=("$xmlfile")
done < <(find "$dir" -name "*.xml" -type f -print0)
open -W "${files[@]}"
done < <(awk '{print $2}' failingAll)

假设您不想退出编辑器,并假设它可以通过后续调用 open 获取一组新文件,那么以下操作也可能有效:

while IFS= read -u 3 -r dir; do
files=()
while IFS= read -r -d '' xmlfile; do
files+=("$xmlfile")
done < <(find "$dir" -name "*.xml" -type f -print0)
open "${files[@]}"
read
done 3< <(awk '{print $2}' failingAll)

关于linux - 使用 Xargs 等待回车键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30924350/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com