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}

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.

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

hey kpagadala ..
if u need the car_COM_20100409.txt as your file name
then try

basename $ind_file

for desire results.

Hi Posix,

It works, Thanks a lot.