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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell scripting for moving folder specific files into target directory of that country folder.
# 1  
Old 08-23-2017
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

Last edited by naresh2389; 08-23-2017 at 07:57 AM..
# 2  
Old 08-23-2017
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
# 3  
Old 08-23-2017
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
Code:
/etc/conf/UAE and etc/conf/UAE/Misc 
etc/conf/UK
etc/conf/USA

Target Server
Code:
/etc/conf/UAE and etc/conf/UAE/Misc 
etc/conf/UK
etc/conf/USA


Last edited by rbatte1; 08-23-2017 at 08:45 AM.. Reason: Added CODE tags
# 4  
Old 08-23-2017
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

2. Shell Programming and Scripting

Shell script which will check the target file and folder exists and copy it

Hi All, I am a beginner in this and trying to write a shell script in linux which will : 1. Ask for a file name and check if its exists. 2. If file exists only then it will ask for the new target folder, after entering target folder name it will check if it exists. 3. If target folder... (3 Replies)
Discussion started by: ashish_neekhra
3 Replies

3. Homework & Coursework Questions

Shell Scripting , Moving Old file to specific folder

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: There are files stored like 14.Aug.2014.log, 15.Aug.2014.log etc. in a folder $HOME/log you need to find out all... (4 Replies)
Discussion started by: shajoftaj
4 Replies

4. Ubuntu

Shell Scripting , Moving Old file to specific folder

There are files stored like 14.Aug.2014.log, 15.Aug.2014.log etc. in a folder $HOME/logyou need to find out all the log files of last 1 month and move them into $HOME/logs/lastmonth/ this should be implemented with reference of file name. ---------- Post updated at 12:30 PM ----------... (3 Replies)
Discussion started by: shajoftaj
3 Replies

5. UNIX for Dummies Questions & Answers

Moving files to a folder with a variable name

hello there- first post here- maybe someone can help- Basically I am trying to copy the contents of a folder to a different folder that has a variable name. the content I want to copy would be in a folder on my desktop called: myfolder the variable folder would look something like: ... (3 Replies)
Discussion started by: infothelonghaul
3 Replies

6. Shell Programming and Scripting

rsync delete specific files - from different target folder

Hi, I need to use rsync to delete multiple files(only specified files not all) using --delete option, these files are located in different target folders. Instead of running rsync command multiple times for each file, can we achieve this with one time execution? your help is much... (0 Replies)
Discussion started by: MVEERA
0 Replies

7. UNIX for Advanced & Expert Users

Moving 1000s of files to another folder

Hi, I need to move 1000s of files from one folder to another. Actually there are 100K+ files. Source dir : source1 Target dir : target1 Now if try cp or mv commands I am getting an error message : Argument List too long. I tried to do it by the time the files are created in the... (1 Reply)
Discussion started by: unx100
1 Replies

8. Shell Programming and Scripting

Script for moving files from one folder to other

Hi I need to move last 1 year old files from one folder to another location on same server.How to write a shell script for the same? thanx Lalit (8 Replies)
Discussion started by: lalitkumar
8 Replies

9. Shell Programming and Scripting

Script for moving files from one folder to other

Hi All I need a shell script for move the 1 year old files from one folder to another folder with date and time. How to write a shell script for the same pls hepl me out. thanx in advance Thanx Lalit (2 Replies)
Discussion started by: lalitkumar
2 Replies

10. Shell Programming and Scripting

Moving Files from one folder to another folder

Hi, I have a folder which contain the log files. The folder may contain sub folders as well. I want to move the contents of the log folder to tmp folder periodically. I have used the command. LOG_DIR=/logs DESTINATION_DIR=/tmp/logs find ${LOG_DIR} -mtime +1 -exec mv {}... (10 Replies)
Discussion started by: farooqpervaiz
10 Replies
Login or Register to Ask a Question