Shell scripting for moving folder specific files into target directory of that country folder.

I need help to write shell script to copy files from one server to another server.

Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target server Misc folder Under UAE Folder only).While copying i have to check the folder is UAE or not.

Source Directory UAE -> Files and UAE->Misc-> Files

Welcome naresh2389,

I have a few to questions pose in response first:-

  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)

Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.

We're all here to learn and getting the relevant information will help us all.

Kind regards,
Robin

Hi Robin,

I am using shell scripting(Linux) for this.
I am trying to use scp to copy the files but i thinking on how to copy files from folder(UAE) and then files inside Misc folder(Inside UAE) into target server.(UAE folder).Need to check whether folder is UAE or UK etc.

I have code to check the country and i passing that dynamically from user entered value.

Source folder.For example user will enter UK and then i will go etc/conf/Uk and copy files and paste it in target server.(Misc files in Uk>Misc->Files).

Source Server

/etc/conf/UAE and etc/conf/UAE/Misc 
etc/conf/UK
etc/conf/USA

Target Server

/etc/conf/UAE and etc/conf/UAE/Misc 
etc/conf/UK
etc/conf/USA

Can you show us:-

  • The output from uname -a in CODE tags (highlight the output and click the tool/button with co over de )
  • The output from ps -f to show which shell you are using
  • What you have tried
  • What errors you get

Can I assume that the directories should all be fully qualified? (with a leading / ) What you have shown is one fully qualified and two from the current directory, wherever your shell might be.

Robin