line by line reading of the lines in list

line by line reading of the lines in list

Post by enginee » Thu, 15 May 2003 03:34:52



Hi,

I want to read the list line by line and then want to compare these line
with filenames in the directory. When I use FOR loop it does it, but I am
not able to get the required result.

e.g.

linelist="          ###need to find files with these names in dir1 e.g.
file1=aaaaaaaaaa
aaaaaaaaaa
bbbbbbbbb
cccccccccc"

### dir1 consists of only two files called first, third
for lines in $linelist ; do

done

# I tried several combinations, so may the code above may not be completely
correct in syntax at this moment.

The output (foundfiles) from this is:
aaaaaaaaaa
cccccccccc

But, I want:
aaaaaaaaaa
            ### leaving this line blank because "bbbbbbbbbb" file was not
present in the directory
cccccccccc

Many thanks for your help

 
 
 

line by line reading of the lines in list

Post by Barry Margoli » Thu, 15 May 2003 04:11:23




>### dir1 consists of only two files called first, third
>for lines in $linelist ; do

>done

># I tried several combinations, so may the code above may not be completely
>correct in syntax at this moment.

>The output (foundfiles) from this is:
>aaaaaaaaaa
>cccccccccc

>But, I want:
>aaaaaaaaaa
>            ### leaving this line blank because "bbbbbbbbbb" file was not
>present in the directory
>cccccccccc

for lines in $linelist; do

  if [ $count -gt 0 ]
  then echo $lines
  else echo ''
  fi
done > foundfiles

--

Genuity Managed Services, a Level(3) Company, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

1. line by line without using echo "$i" | while read line?

i=$(ps -ef)
and
I do not want to use
echo "$i" | while read line
any options?

The reason I do not want to use "| while"
is that it will run a subshell:

pipe()                                          = 3 [4]
fork()                                          = 1089
    Received signal #18, SIGCLD [caught]
      siginfo: SIGCLD CLD_EXITED pid=1089 status=0x0000

And the environment variable defined in the while loop
can not get out of the loop in Borne shell.

I tried

IFS="\n"
for j in $i

but it does not work.

Thanks.

2. WGR614 router act only as an access point? No seperation of WAN and LAN?

3. read from stdin while reading line by line a file

4. X Sun Question

5. Linux permanent Line (connection two linux machines over a leased line (permanent telephone line)

6. UNIX system command produces child dies?

7. one liner which prints n lines before and m lines after the line found by grep

8. Rendition Verite 2100 support in Linux??????

9. Find a string, delete that line, delete 1 line before it and all lines after it...

10. How to read line by line of a file

11. HELP: How do I read a file line-by-line without getting spaces stripped?

12. read a file line by line

13. How to read line by line from a file?