使用ps命令在bash中连接变量时出现冗余问号

时间:2017-12-12 08:13:53

标签: bash

运行bash文件download.sh,scp显示"没有这样的文件"错误。所以我尝试运行命令ps -efj | grep scp和控制台输出:

love@192.168.1.105:/home/storage/static/test/res/house/res.zip_b077f446? ../logs/static/test/res/house/

文件名中出现冗余问号,我认为会导致错误信息"没有这样的文件"。但echo $SOURCE输出为static/test/res/house/res_update.zip_61b25e4b,没有问号。

download.sh

#!/bin/bash

FILE=love@192.168.1.105:/home/storage/
while read p; do
    PART_DIR=$(echo $p | awk 'BEGIN{FS=OFS="/"}{NF--; print}')
    DEST_DIR="../logs/${PART_DIR}" # directory for saving files 
    mkdir -p "${DEST_DIR}"
    SOURCE="${FILE}${p}" 
    echo $SOURCE # debug, output: static/test/res/house/res_update.zip_61b25e4b 
    scp -P 19061 $SOURCE "${DEST_DIR}/"
done <../logs/file.txt

file.txt的

static/test/res/house/res.zip_b077f446
static/test/res/house/res_update.zip_61b25e4b

0 个答案:

没有答案