The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Not access variable outside loop when a reading a file ricardo.ludwig Shell Programming and Scripting 4 05-24-2009 12:14 AM
help with a 'while read' loop to change the names of files starsky Shell Programming and Scripting 6 03-01-2008 01:47 PM
Reading 5 Students names and grades using while loop???? dlbomber1 Shell Programming and Scripting 1 11-26-2007 02:46 AM
Variable names Bab00shka UNIX for Dummies Questions & Answers 2 11-11-2005 11:45 AM
Variable assignment for file names. jagannatha UNIX for Dummies Questions & Answers 2 05-29-2003 05:38 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-11-2009
spkandy spkandy is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 13
Smile File Names in a Variable in a loop

Hi All ,
I am having confusion in a shell script. Please guide me.
I need to get multiple files (number of files vary time to time, file names are separated by '|') using FTP get from the remote server.

Actually, i call the FTP function in a loop. At the last step, i need to move all the get files to the target directory.

<Sample Code>

FILE_COUNT=`echo "${SOURCE_FILE}" | tr '|' '\n' | wc -l
COUNTER=1
while [ ${COUNTER} -le ${FILE_COUNT} ]
do

FILE=`echo ${SOURCE_FILE} | cut -d '|' -f${COUNTER}`
<FTP Function>
if [[ ${COUNTER} = ${FILE_COUNT} ]]
then
mv <All the Source File Names> <Target Directory>
fi
done


<Problem>
How can I hold all the file names in a variable like below in the loop.
FileNames=FileName1 FileName2 FileName3 ... FileNameN
mv $FileNames $TargetDirectory

Please help me how can i achieve.

Thanks,
Kanda.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0