Help on Moving files from one location to another location


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help on Moving files from one location to another location
# 1  
Old 04-08-2010
Help on Moving files from one location to another location

Hi,

I am new to unix and shell scripting.

Please help me in resolving the below issue.

In my shell script I have a variable which stores the different files with the path. Now I need to move all the files one by one to another location.

----
1. ORG_NAME=/home/usr1/car_*_${today}.txt --This will store multiple files with paths as specified.

2. concatinate_files=`echo "$ORG_NAME" |grep '*'` --
3. doccoutnt=`ls -l $concatinate_files | wc -l` -- This variable stores the number of files (Ex: 5)
4..?

Now I want to move the files in "concatinate_files" to another directory using a while loop (using doccount).

Please tell me how to get the only file name from my variable "concatinate_files" and store it $ind_file


mv $concate_files home/usr2/drb/archive/${ind_file}.${now}
# 2  
Old 04-08-2010
I am not getting you fully, Can you pls give an example? In your case, you can store only one value to a variable.

-Nithin.
# 3  
Old 04-09-2010
I have a variable which stores a multiple values with a space between each file.

Now I need to seperate the each file and move the file to different path.

"echo concatinate_files" show the below value:
"/home/usr1/car_COM_20100409.txt /home/usr1/car_MOM_20100409.txt /home/usr1/car_REN_20100409.txt /home/usr1/car_SOM_20100409.txt"

If you see the above value it has 4 different files. Using the below command I am seperating each file like ..

export ind_file=`echo $concatinate_files |cut -f1 -d ' ' `--this gives me each file one by one Ist value I will get it as /home/usr1/car_COM_20100409.txt".

now my problem is how to seperate the only file name from the $ind_file.

Also I need a for loop to loop through the process based on number of files in $concatinate_files.

Thanks
# 4  
Old 04-09-2010
hey kpagadala ..
if u need the car_COM_20100409.txt as your file name
then try
Code:
basename $ind_file

for desire results.
# 5  
Old 04-09-2010
Hi Posix,

It works, Thanks a lot.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Moving a file from one location to another.

Hi, I've done a set of operations on some text files using a someexecutuble.jar file, which is internally calling some python scripts. Post that, in same location, my jar created some log files. However, i'm not able to re-direct the log files to some other location in my windows directory.... (1 Reply)
Discussion started by: arjun_arippa
1 Replies

2. Shell Programming and Scripting

Copy files from one location to another

I have below files in one location /test/files and also for each dates there are similar files A20130924.0000-0005_file1 A20130924.0000-0005_file2 A20130924.0005-0010_file1 A20130924.0005-0010_file2 . . . A20130924.2355-0000_file1 A20130924.2355-0000_file2 If i execute the script like... (4 Replies)
Discussion started by: Saidul
4 Replies

3. Shell Programming and Scripting

Help with copying the list of files from one location to other location

A) I would like to achive following actions using shell script. can someone help me with writing the shell script 1) Go to some dir ( say /xyz/logs ) and then perform find operation in this dir and list of subdir using find . -name "*" -print | xargs grep -li 1367A49001CP0162 >... (1 Reply)
Discussion started by: GG2
1 Replies

4. Shell Programming and Scripting

How to find a existing file location and directory location in Solaris box?

Hi This is my third past and very impressed with previous post replies Hoping the same for below query How to find a existing file location and directory location in solaris box (1 Reply)
Discussion started by: buzzme
1 Replies

5. Shell Programming and Scripting

How to copy a file from one location to another location?

I have file file1.txt in location 'loc1'. Now i want a copy of this file in location 'loc2' with a new file called test.txt. Please help me how to do this in shell script. (1 Reply)
Discussion started by: vel4ever
1 Replies

6. Shell Programming and Scripting

File created in a different location instead of desired location on using crontab

Hi, I am logging to a linux server through a user "user1" in /home directory. There is a script in a directory in 'root' for which all permissions are available including the directory. This script when executed creates a file in the directory. When the script is added to crontab, on... (1 Reply)
Discussion started by: archana.n
1 Replies

7. Shell Programming and Scripting

Shell Script for Copy files from one location to another location

Create a script that copies files from one specified directory to another specified directory, in the order they were created in the original directory between specified times. Copy the files at a specified interval. (2 Replies)
Discussion started by: allways4u21
2 Replies

8. Shell Programming and Scripting

Put one string from one location to another location in a file

Hi Everyone, I have 1.txt here a b c' funny"yes"; d e The finally output is: here a b c d e' funny"yes"; (1 Reply)
Discussion started by: jimmy_y
1 Replies

9. Shell Programming and Scripting

Transfer files from one location to another location

Hi, i have to transfer of files of User1 located in Location1 to user2 located in Location2 using shell script. Please suggest me. (1 Reply)
Discussion started by: KiranKumarKarre
1 Replies

10. UNIX for Advanced & Expert Users

copy files from one location to similar location

I need help in forming a script to copy files from one location which has a sub directory structure to another location with similar sub directory structure, say location 1, /home/rick/tmp_files/1-12/00-25/ here 1-12 are the number of sub directories under tmp_files and 00-25 are sub... (1 Reply)
Discussion started by: pharos467
1 Replies
Login or Register to Ask a Question