Created
January 23, 2026 12:54
-
-
Save mainframed/0c64b69757a37b3df35f5fd9c9ad3676 to your computer and use it in GitHub Desktop.
getfiles.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| REMOTE_USER="user" | |
| REMOTE_HOST="hostname" | |
| REMOTE_PASSWORD="password" | |
| LOCAL_DIR="." | |
| while read remote_file; do | |
| # Remove leading slash from the path | |
| local_path="${remote_file#/}" | |
| local_file="$LOCAL_DIR/$local_path" | |
| # Create the local directory structure | |
| mkdir -p "$(dirname "$local_file")" | |
| # Copy the file | |
| sshpass -p "$REMOTE_PASSWORD" ssh "$REMOTE_USER@$REMOTE_HOST" cat "$remote_file" > "$local_file" | |
| echo "Copied: $remote_file" | |
| done < filelist.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment