Skip to content

Shell script

Loop line of txt file

while read p; do
    echo "$p" 

    ## trim white space
    trimmed_line="$(echo -e "${p}" | tr -d '[:space:]')"

    newfilename=$trimmed_line.sql

    ## append to template.sql and create new file
    echo "\set var $log_hash" | cat - template.sql >  "sql/$newfilename"    


done <file.txt

Using ssh to copy server folder to local

scp -r userid@host.address:/path/of/folder /target/local/folder