Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Location
    SW London
    Posts
    9

    Unanswered: 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

  2. #2
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    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.

  3. #3
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •