Help with read command

Help with read command

Post by vogel0.. » Thu, 12 Oct 2000 04:00:00



My script looks like this

#!/bin/ksh
for i in 'ls'
do

while read num rest
do
...
done < $i

done

I want to read every file in the directory.
It works fine with reading the first file in the directory, but it
crashes at the second file with the message:
Can't open file

Help would be great!

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Help with read command

Post by Jehs » Thu, 12 Oct 2000 04:00:00



> for i in 'ls'
> do
> while read num rest
> do
> ...
> done < $i
> done

Instead, try this:
#!/bin/ksh
for i in *; do
  [ -f $i ] || continue
  while read num rest; do
    ...
  done < $i
done

Moshe

--

wreck.org bellsouth.net resnet.gatech.edu burdell.org yo.dhs.org gooning.org

usa.net; ICQ 1900670

 
 
 

Help with read command

Post by bmar.. » Thu, 12 Oct 2000 04:00:00



   >I want to read every file in the directory.
   >It works fine with reading the first file in the directory, but it
   >crashes at the second file with the message:
   >Can't open file
   >Help would be great!
Maybe the second file is a directory?
for i in *
do
  if [ -f "$i" ]
  then while read ...

Net-Tamer V 1.08X - Test Drive

 
 
 

Help with read command

Post by Peter Sundstro » Fri, 13 Oct 2000 05:31:09



> My script looks like this

> #!/bin/ksh
> for i in 'ls'
> do

> while read num rest
> do
> ...
> done < $i

> done

> I want to read every file in the directory.
> It works fine with reading the first file in the directory, but it
> crashes at the second file with the message:
> Can't open file

> Help would be great!

Remember that ls will list files, directories, links etc.

Either use something like

for i in `find . -type f -print`

or

for i in *
do
   [ -f $i ] || continue

 
 
 

1. Help for read command

Can you help me to solve this problem
I have a function to read input

readCommand() {
Res=""
echo Gimme a value
read Read
echo "exit ok from this function"

If  I resize the window when the script is ready to receive the input then
the read fail and the execution exit readCommand function without assign the
input value to Res.
Helpppppppppp!!!
Thanks

2. Solaris 2.4 x86 problem with SIMM RAM

3. Help for read command 2

4. How to get CPU, Memory, Disk Utilization on HP-UX 11.x

5. Help me with the command Read.

6. finding files

7. HELP! read command on digital UNIX - C shell

8. Stats comp.os.linux.networking (last 7 days)

9. need to pipe a find or locate command into the rm command....PLEASE help!

10. I/O read error reading from internal cd HELP

11. HELP: "TOP" Command and "SZ" command

12. Help: Program to read from EOR end of last read?