Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 如何输入剪贴板查找命令?_Bash_Find_Clipboard - Fatal编程技术网

Bash 如何输入剪贴板查找命令?

Bash 如何输入剪贴板查找命令?,bash,find,clipboard,Bash,Find,Clipboard,我需要做的是传递一个要查找的文件名列表,并让find打印这些文件,路径是xargs find的-exec,对它们执行命令也可以 我很清楚find可以读取文件名,读取行: while read line; do find . -name "$line" -exec command '{}' \; ;done <file 但是使用find的想法当然是能够递归地搜索列表中的任何文件 如果以下操作有效,那就太好了,但是使用此查找只读取列表中的第一个文件: xsel -b -o | while

我需要做的是传递一个要查找的文件名列表,并让find打印这些文件,路径是xargs find的-exec,对它们执行命令也可以

我很清楚find可以读取文件名,读取行:

while read line; do find . -name "$line" -exec command '{}' \; ;done <file
但是使用find的想法当然是能够递归地搜索列表中的任何文件

如果以下操作有效,那就太好了,但是使用此查找只读取列表中的第一个文件:

 xsel -b -o | while read line; do find . -name "$line" -print0 | xargs -0 command ;done
如果这是可以纠正的,那么这将解决问题

使用重定向剪贴板,您可以通过管道连接到xargs,而不是查找:


我还没有测试,但是如果你把它转过来呢?xsel-b-o |同时读取行;一定要找到-name$line-print0;完成| xargs-0命令,并且可能为了安全起见,在xargs选项中添加一个-r。我认为这可能会将xargs与while循环分开-bash报告没有指定文件dit看起来不错,但在bash中没有结果。。。对不起,我刚才的剪贴板内容有误。它工作得很好!我已经测试过了,它可以在我的机器上运行。如果我不为你工作,请尝试更换。
 xsel -b -o | while read line; do find . -name "$line" -print0 | xargs -0 command ;done
$ xsel -b -o | xargs -I X -r -n 1 find . -name X -exec command '{}' \;