[英]Bash/ echo and pattern
I have a file which starts with " xx
", I want to find it and do some bash commands on it. 我有一个以“
xx
”开头的文件,我想找到它并对其执行一些bash命令。
In order to find it, I wrote the next command: 为了找到它,我编写了下一条命令:
b= 'echo $(ls -r /var/www/xx*)'
But it say that No such file or directory
, while xxbr7.log
is there. 但是它说在
xxbr7.log
那里No such file or directory
。
How I can find it? 我如何找到它?
Because you have a space after the =
so it is interpreting the entire 'echo $(ls -r /var/www/xx*)'
string as a command to execute (with the variable b
set to an empty string in its environment.) 因为
=
后面有一个空格,所以它将整个'echo $(ls -r /var/www/xx*)'
字符串解释为要执行的命令(变量b
在其环境中设置为空字符串)。 )
If you're trying to set b
to the string echo /var/www/xxbr7.log
then you want: 如果尝试将
b
设置为字符串echo /var/www/xxbr7.log
则需要:
b='echo $(ls -r /var/www/xx*)'
with no space after the =
character. =
字符后没有空格。
If you're trying to set it to just the string /var/www/xxbr7.log
then you can simplify it: 如果您尝试将其设置为仅字符串
/var/www/xxbr7.log
则可以对其进行简化:
b=$(ls -r /var/www/xx*)
Or for the special case where there's only one file doing $(ls -r /var/www/xx*)
is unnecessary, you could just say /var/www/xx*
或者对于仅需要一个文件执行
$(ls -r /var/www/xx*)
的特殊情况,您可以说/var/www/xx*
b=/var/www/xx*
You can use the command: 您可以使用以下命令:
find . -name 'mystring*'
to find. 找到。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.