It is currently Tue, 07 Dec 2021 01:31:47 GMT



 
Author Message
 line by line reading of the lines in list
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
    find "${@:-.}" -name $lines -print | ? foundlines
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



 Sun, 30 Oct 2005 02:34:52 GMT   
 line by line reading of the lines in list
In article <gVawa.1589142$sj7.68153269@Flipper>,

for lines in $linelist; do
  count=`find "${@:-.}" -name $lines -print | wc -l`
  if [ $count -gt 0 ]
  then echo $lines
  else echo ''
  fi
done > foundfiles

--
Barry Margolin, barry.margo...@level3.com
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.



 Sun, 30 Oct 2005 03:11:23 GMT   
 
   [ 2 post ] 

Similar Threads

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

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

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

4. Reading a script file line by line.

5. How to read line by line in csh

6. Read line at at time and split up that line

7. Using read within a loop that parses a file line by line

8. read pipe line by line


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software