命令以查找目录中的所有文件并为参数合并它们? [英] Command to find all files in a directory and concat them for a parameter?

查看:38
本文介绍了命令以查找目录中的所有文件并为参数合并它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个命令,该命令使用特定的partern查找目录中的所有文件,让我们说"* .txt"并在BASH中从中创建参数列表.

因此,如果目录包含:file1.txtfile2.txtfile3.txt废话

我需要字符串"file1.txt file2.txt file3.txt"

我知道有一个BASH/Unix命令,但是我不记得它了:-S.找到"对我没有用...

谢谢!

Yvan Janssens

解决方案

听起来像您想要 xargs .

I'm looking for a command which finds all files in a directory using a specific partern, lets say "*.txt" and create a list of parameters from it in BASH.

So if the dir contains: file1.txt file2.txt file3.txt nonsense.c

I need the string "file1.txt file2.txt file3.txt"

I knew there was a BASH/Unix command for this, but I can't remember it :-S. "find" didn't work for me...

Thanks!

Yvan Janssens

解决方案

It sounds like you want ls and xargs.

这篇关于命令以查找目录中的所有文件并为参数合并它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆