相关疑难解决方法(0)

如何在find中排除目录.命令

我正在尝试find为所有JavaScript文件运行命令,但如何排除特定目录?

这是find我们正在使用的代码.

for file in $(find . -name '*.js')
do 
  java -jar config/yuicompressor-2.4.2.jar --type js $file -o $file
done
Run Code Online (Sandbox Code Playgroud)

linux shell find

1250
推荐指数
26
解决办法
92万
查看次数

如何在sh中使用'find'的'-prune'选项?

我不太明白"男人发现"给出的例子,有人能给我一些例子和解释吗?我可以在其中组合正则表达式吗?


更详细的问题是这样的:写一个shell脚本,changeall,它有一个像"changeall [-r | -R]"string1""string2"这样的接口.它将找到后缀为.h,.C的所有文件,.cc或.cpp并将所有出现的"string1"更改为"string2".- r是仅保留当前目录或包含subdir的选项.注意:1)对于非递归情况,不允许"ls" ,我们只能使用'find'和'sed'.2)我试过'find -depth'但它不受支持.这就是为什么我想知道'-prune'是否可以帮助,但是不明白'男人发现'.


EDIT2:我正在做作业,我没有详细提问,因为我想自己完成.既然我已经完成并把它交给我,现在我可以陈述整个问题.此外,我设法在不使用-prune的情况下完成了作业,但无论如何都想学习它.

regex shell find manual

207
推荐指数
5
解决办法
11万
查看次数

无法修改git bash Windows快捷方式

在Windows 7下,我想更改Git Bash Here shell扩展命令窗口的设置,例如宽度,高度和字体.但是当我这样做时,我收到错误"无法修改快捷方式".

我可以使用"以管理员身份运行..."在"开始"菜单中修改Git Bash的快捷方式,但这仅适用于从"开始"菜单打开的Bash窗口.它不适用于"Git Bash Here"shell扩展,右键单击上下文菜单中没有"以管理员身份运行..."选项.

你怎么做呢?

git bash windows-7

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

从"du"中排除所有被拒绝的权限消息

我试图评估一些Unix用户帐户的磁盘使用情况.简单地说,我使用以下命令:

du -cBM --max-depth=1 | sort -n
Run Code Online (Sandbox Code Playgroud)

但我看到很多错误信息如下.如何从显示中排除所有此类"权限被拒绝"的消息?

du: `./james/.gnome2': Permission denied
Run Code Online (Sandbox Code Playgroud)

通过将"find"替换为"du",我的请求可能与以下列表非常相似.

如何从"查找"中排除所有"权限被拒绝"的消息?

以下线程不起作用.我想我正在使用bash.

使用--exclude,grep -v或sed从du命令输出中排除隐藏文件

sorting shell warnings suppress-warnings du

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

查找中的权限被拒绝:为什么我们需要2>&1?

我最近在搜索使用该命令搜索文件时过滤掉" 权限被拒绝 "错误的方法find,我找到了这个链接:

如何从"查找"中排除所有"权限被拒绝"的消息?

以下是从链接中找到的答案:

find . -name "filename" 2>&1 | grep -v 'permission denied'
Run Code Online (Sandbox Code Playgroud)

虽然这个答案有效,但我并不完全理解为什么我们需要2>&1(将stderr重定向到stdout).

命令的输出是否find . -name "filename" | grep -v 'Permission denied'已重定向到stdout?

error-handling bash find io-redirection

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

Linux find 命令权限被拒绝

我想过滤掉不必要的信息“权限被拒绝”。这些是命令“ find -type f -name sources.list”的输出

find: './run/lxcfs': Permission denied
find: './run/sudo': Permission denied
find: './run/lvm': Permission denied
find: './tmp/systemd-private-99eef94819d84080adc7df3e60efee5b-systemd-timesyncd.service-HE48k9': Permission denied
find: './lost+found': Permission denied
find: './dev/vboxusb': Permission denied
find: './root': Permission denied
./etc/apt/sources.list
find: './etc/sudoers.d': Permission denied
Run Code Online (Sandbox Code Playgroud)

我尝试将“ ! -readable -prune”与上述find命令结合使用以抑制“权限被拒绝”信息,但它仍然不起作用。

shell find

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