If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > for loop not behaving how i want

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-23-04, 08:30
DubbsNix DubbsNix is offline
Registered User
 
Join Date: Dec 2003
Location: SW London
Posts: 9
for loop not behaving how i want

Here is my problem.

I create a .lst file containing the following: (using an FTPls)

-rw-rw-r-- 1 dvpears prism 19040 Sep 25 10:56 dax_e_ic_20030828.csv
-rw-rw-r-- 1 dvpears prism 19042 Sep 25 10:56 dax_e_ic_20030829.csv
-rw-rw-r-- 1 dvpears prism 71 Sep 25 10:56 dax_e_in_20030828.csv
-rw-rw-r-- 1 dvpears prism 71 Sep 25 10:56 dax_e_in_20030829.csv

Then I want to cycle through the contents of the .lst file, record by record, assigning each column into a variable.

My loop would be:
for rec in $(cat $LIVE_WORK/serverfiles.lst)
do
.
.
.

The problem I have is that for the 1st row in the .lst file, $rec is returning the following:
-rw-rw-r--
instead of
-rw-rw-r-- 1 dvpears prism 19040 Sep 25 10:56 dax_e_ic_20030828.csv

I think it is because of the spaces between each data item. How do I get the whole row assigned in $rec?

Any help greatly appreciated
Reply With Quote
  #2 (permalink)  
Old 02-23-04, 08:54
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
You also got an answer on Tek-Tips.
For the other users of this forum :
Code:
while read mode links owner group size time1 time2 time3 name
do
   . . .
done < $LIVE_WORK/serverfiles.lst
__________________
Jean-Pierre.
Reply With Quote
  #3 (permalink)  
Old 02-23-04, 09:33
DubbsNix DubbsNix is offline
Registered User
 
Join Date: Dec 2003
Location: SW London
Posts: 9
Well spotted. I actually sent on behalf of a user here and he's very happy now. The replies are sorted.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On