简体   繁体   中英

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 :

shswitch_313083_126.138.36.253_**11894**_OUTPUTCONFIG

and copy it elsewhere. When i'm trying this above, that's what linux says :

cp: cannot stat `/opt/exploit/dev/florian/scan-allied/working-dir/shswitch_\\'313083\\' \\'126.138.36.253\\' \\'*\\'_OUTPUTCONFIG': No such file or directory

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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