bash - 使用 bash 脚本从服务器中查找和 SCP 文件
问题描述
以下是我的 bash 脚本:
#!/bin/bash
echo "directory: $1"
echo "filename: $2"
echo "username: $3"
echo "destination: $4"
echo "host: $5"
SEARCH=$2*
echo "Search: $SEARCH"
for i in 'ssh $3@$5 find $1 -type f -name SEARCH'
do
echo $PWD
FILE=$i
echo "FILE= $FILE"
scp $3@$5:$FILE $4
done
这是我的输出:
directory: **Correct Directory**
filename: **Correct Filename**
username: **Correct username**
destination: ./STORAGE
host: **Correct Host**
Search: filename*
/Users/ranjanasinha/ransinha/POS-INVESTIGATION
FILE= ssh $3@$5 find $1 -type f -name $SEARCH
scp: ssh: No such file or directory
cp: $3@$5: No such file or directory
cp: find: No such file or directory
cp: $1: No such file or directory
cp: -type: No such file or directory
cp: f: No such file or directory
cp: -name: No such file or directory
我期待 FILE 有找到的文件名。我的问题是为什么“我”没有找到找到的文件?命令有什么问题?
解决方案
推荐阅读
- javascript - 解析方法并返回结果
- scala - 约束案例类和特征的类型参数
- javascript - 未捕获的 SyntaxError:await 仅在静态函数内的异步函数中有效
- swift - 如何使用 Swift 在 NSOutlineView 中搜索字符串
- c# - C# 只获取 X 个文件
- flutter - 如何在 Flutter 中重置所有复选框项目和附加到它的数据?
- python - 在 PyCharm/Windows 上安装 tkinter
- php - 如何在 WHERE 子句中创建包含 PHP implode() 方法的 WP 准备语句
- matlab - Matlab 中的 For 循环定义
- typescript - 打字稿:类型变量在某些情况下不进行类型检查