logo
down
shadow

SFTP bash shell script to copy the file from source to destination


SFTP bash shell script to copy the file from source to destination

By : Asha Anitha Devi
Date : November 22 2020, 04:01 AM
I wish this helpful for you In a simple case such as this, you could use scp instad of sftp and specify the files to copy on the command line:
code :
 scp $localpath/* username@10.42.255.209:/$remotepath/
  echo "put $localpath/* $remotepath" | sftp username@10.42.255.209
sftp username@10.42.255.209 << EOF
put $localpath/fileA $remotepath/
put $localpath/fileB $remotepath/
EOF
 sftp -b ./sftp_commands.txt username@10.42.255.209


Share : facebook icon twitter icon
Bash Shell Script to copy files from source to destination

Bash Shell Script to copy files from source to destination


By : nishant
Date : March 29 2020, 07:55 AM
should help you out I have a question related to my bash shell script. Basically, I need to develop a script that copies certain files from one directory to another. Sounds easy, however, its quite a challenge for me and I hope some of you might help me. So script should work like this: , If you want to use the find command, try this:
code :
find SRCPATH -exec mkdir -p DSTPATH/$(dirname "{}") \; -exec cp --parents "{}" DSTPATH \;
#!/bin/bash
srcpath=$1
dstpath=$2
if [ ! -d "$srcpath" ]; then
    echo "Source path: $srcpath doesn't exist"
    exit 1
fi
mkdir -p "$dstpath"
cp -r "$srcpath/*" "$dstpath"
Simple shell/bash based sftp script to upload a file to root directory of destination server

Simple shell/bash based sftp script to upload a file to root directory of destination server


By : bahan sb
Date : March 29 2020, 07:55 AM
I wish this help you I need to upload a file from source unix server to destination unix server (supports sftp). i'm using simple script below:- , Simply use a SFTP batch file:
code :
sftp -b batchfile.sftp userid@destination_server
put myfile /
How to copy only that data to a file which is not present in that file in shell script / bash?

How to copy only that data to a file which is not present in that file in shell script / bash?


By : Don Martin
Date : March 29 2020, 07:55 AM
will be helpful for those in need I have to put some data in a file which should be unique. suppose in file1 I have following data. , Easiest way: this sholud add non-matching line in f1
code :
diff -c f1 f2|grep ^+|awk -F '+ ' '{print $NF}' >> f1
diff -c f1 f2|grep ^+|awk -F '+ ' '{ for(i=2;i<=NF;i++)print $i}' >> f1
$ cat f1
ABC
XYZ
PQR
$ cat f2
MNO
DES
ABC
$ ./compareCopy f1 f2
-----------------------------------------------------
 comparing f1 f2
-----------------------------------------------------
Lines check - DONE
$ cat f1
ABC
XYZ
PQR
DES
MNO  
#!/bin/sh

if [ $# != "2" ]; then
  echo
  echo "Requires arguments from command prompt"
  echo "Usage: compare <file1> <file2>"
  echo
  exit
fi

proc="compareCopy"
#sort files for line by line compare
cat $1|sort > file1.tmp
cat $2|sort > file2.tmp

echo "-----------------------------------------------------"
echo " comparing $1 $2" |tee ${proc}_compare.result
echo "-----------------------------------------------------"

file1_lines=`wc -l $1|cut -d " " -f1`
file2_lines=`wc -l $2|cut -d " " -f1`

#Check each line
x=1
while [ "${x}" -le "${file1_lines}" ]
do
  f1_line=`sed -n ${x}p file1.tmp`
  f2_line=`sed -n ${x}p file2.tmp`

        if [ "${f1_line}" != "${f2_line}" ]; then
         echo "line number ${x} don't match in both $1 and $2 files" >> ${proc}_compare.result
         echo "$1 line: "${f1_line}"" >> ${proc}_compare.result
         echo "$2 line: "${f2_line}"" >> ${proc}_compare.result
         # so add this line in file 1
         echo $f2_line >> $1
        fi
x=$[${x} +1]
done

rm -f file1.tmp file2.tmp
echo "Lines check - DONE" |tee -a ${proc}_compare.result
copy the recently modified file from source to destination in Batch script

copy the recently modified file from source to destination in Batch script


By : Priyank Solanki
Date : March 29 2020, 07:55 AM
Hope this helps How to copy the recently modified file from source to destination.
linux shell script source destination copy directory

linux shell script source destination copy directory


By : Elston Sa
Date : September 27 2020, 05:00 AM
like below fixes the issue I want to copy files from my current directory to a directory which is pointed out by user(destination). Destination directory will be input by user during the execution of the script. Command should create directory and add write permission and check the required size. Basically a Linux installation kind of script. I have written a basic script using "cp" command , but I want advanced script which takes input from user and copies accordingly. Any idea on this? , Below's some sample code to get you started :
code :
read -p "Input target dir : " choice
if [ ! -d "$choice" ]  
then
    echo "invalid directory"
    exit 1
else
    cp -r /source/dir/* "$choice"
fi
Related Posts Related Posts :
  • google big query command line executing complex query giving error unexpected '('
  • Bash script with sendmail delivers email when executed manually but not from crontab
  • Awk and a global variable
  • Linux bash script: using ls with glob and getting output in variable not working
  • Shell program, error in for loop. Variable not used
  • bash: bash script gives Bad substitution error
  • Piping grep matches into sed
  • How to execute script that opens interactive and continues inside container
  • Strange behavior about ”ls | while read" with ffmpeg in shell script
  • Docker shell script not parameterizing as expected
  • using bash how can i get the network device name and ip address in one line?
  • Renaming files with a specific scheme
  • Reading asterisk character (*) from a file in bash
  • How change source with a bash function
  • how do I create an array with dynamic name in bash
  • How can i select particular items of array with Bash
  • How to understand this line of Bash script?
  • How do I capture strings between a string match and a new line while ignoring newline and space in between in bash?
  • How to backup files before overwriting them with rsync
  • How can I output the number on the nth position in a string?
  • Bash. Associative array iteration (ordered and without duplicates)
  • ANSI escape code weird behavior at end of line
  • configure confixtx.yaml file?
  • 'Bad Substitution' sourcing an auto-completion script as non-root user
  • Echo bash variable in separate bash process
  • How to access a Docker container instance using the image name?
  • How to add a command line argument to my script?
  • How can I delete a file that doesn't have a matching file with a different extension
  • Iterating over arrays, each with a pair of values, to operate on each pair in turn
  • Can't push to github a specific commit that added PNG Images
  • bash: Problems with glob negation and multiple patterns
  • Concatenate string in .csv after x commas using shell/bash
  • Use the answer of a prompt to swap placeholders in another file
  • modify something in several specific files for exemple txt (bash)
  • Bash - Read in a file and replace multiple spaces with just one comma
  • Sed to delete eveything between two non alpha numeric chars
  • How do I escape text in autoconf/m4?
  • Add spaces to the end of some Bash autocomplete options, but not to others?
  • Concatenate strings in bash
  • Shell script that asks user to continue with a y/n
  • Bash+cron: Redirecting, and restoring, stdout and stderr produces permission denied
  • Escaping 'echo' in batch files
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org