简体   繁体   English

Bash cp命令和引号

[英]Bash cp command and quotes

i'm here for a little misunderstanding issue. 我在这里是一个有点误会的问题。

Here's what i have : 这是我所拥有的:

cp "$DIR/working-dir/shswitch_'$codesite' _ '$ip' _ '*' _ OUTPUTCONFIG" "$LOCALDIR/liste/$hostname-$ip"

I want to search for a file which contains words described as var, and a random number in the middle of the file's name like this : 我想搜索一个包含描述为var的单词的文件,并在文件名中间添加一个随机数,如下所示:

shswitch_313083_126.138.36.253_**11894**_OUTPUTCONFIG

and copy it elsewhere. 并将其复制到其他位置。 When i'm trying this above, that's what linux says : 当我在上面尝试时,这就是linux所说的:

cp: cannot stat `/opt/exploit/dev/florian/scan-allied/working-dir/shswitch_\\'313083\\' \\'126.138.36.253\\' \\'*\\'_OUTPUTCONFIG': No such file or directory cp:无法统计`/ opt / exploit / dev / florian / scan-allied / working-dir / shswitch _ \\'313083 \\' \\'126.138.36.253 \\' \\'* \\'_ OUTPUTCONFIG':没有这样的文件或目录

I don't understand why is there backslash in here, and neither why he won't search properly my file. 我不明白为什么这里有反斜线,也为什么他不能正确搜索我的文件。 Can you help please ? 你能帮忙吗?

正确的格式是

cp "$DIR/working-dir/shswitch_${codesite}_${ip}_"*"_OUTPUTCONFIG" "$LOCALDIR/liste/$hostname-$ip"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM