相关疑难解决方法(0)

使 xargs 作为第一个参数传递

我试图产生这种行为:

grep 192.168.1 *.txt
Run Code Online (Sandbox Code Playgroud)

通过 Xargs 将字符串传递到 grep 中,但它会在最后而不是作为第一个参数。

echo 192.168.1 | xargs grep  *.txt
Run Code Online (Sandbox Code Playgroud)

我需要告诉 xargs(或类似的东西)将传入的字符串放在 'grep' 和 '*' 之间,而不是放在最后。

我该怎么做呢?

xargs

80
推荐指数
2
解决办法
8万
查看次数

如何复制和重命名在“查找”功能 Linux 中找到的文件?

我有一个名为的文件夹/home/user/temps,其中包含 487 个文件夹。在每个文件夹中,我都有一个名为 thumb.png 的文件。

我想将所有名为 thumb.png 的文件复制到一个单独的文件夹中,并根据它们来自的文件夹重命名它们。

shell find rename

18
推荐指数
2
解决办法
3万
查看次数

如何告诉 xargs 选择哪个参数?

当 xargs 将第一个命令输出重定向到第二个命令的参数并且无法选择输出的哪个元素的哪个参数时,那么只有一种方法,例如:

ls | xargs file  # there are as many arguments as files in the listing,
                 # but the user does not have too choose himself
Run Code Online (Sandbox Code Playgroud)

现在如果需要选择:

ls | xargs file | grep image | xargs mv.....   # here the user has to 
                                               # deal  with two arguments of mv, first for source second for destination, suppose your destination argument is set already by yourself and you have to put the output into the source argument. 
Run Code Online (Sandbox Code Playgroud)

您如何告诉 xargs …

command-line pipe xargs

14
推荐指数
1
解决办法
2万
查看次数

查找并删除大于特定大小和类型的文件

我想从大型日志文件和备份中清理我的服务器。

我想出了这个:

find ./ -size +1M | xargs rm
Run Code Online (Sandbox Code Playgroud)

但我不想包括 mp3 和 mp4。我只想对日志和存档文件(zip、tar 等)执行此操作

命令会是什么样子?

find

11
推荐指数
2
解决办法
4万
查看次数

寻找模式并移动

我想知道是否有人知道如何找到一个模式,然后将其移动到不同的位置。

例如,我有很多文件名为:

odbc.ini_20110630
odbc.ini_20110639
odbc.ini_20110643
etc...
Run Code Online (Sandbox Code Playgroud)

我想搜索 just 的模式odbc.ini并将它们全部移动到不同的文件夹。

我不太熟悉如何一次执行两个命令(管道)。

bash find

2
推荐指数
1
解决办法
2938
查看次数

标签 统计

find ×3

xargs ×2

bash ×1

command-line ×1

pipe ×1

rename ×1

shell ×1