Record by record

Record by record

Post by Veatri » Sun, 10 Sep 2000 05:34:11



I need to make a shell script that have to
read a text file with recors , reading record by record
and working with the info; but I don't know how to make
a shell script read a text file, any clue ?

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

 
 
 

Record by record

Post by JB » Sun, 10 Sep 2000 05:46:44


cat <filename> | while read <str1> <str2> <the-rest>
    do
    ...

    ...
    done

- puts the first two fields into <str1> and <str2>, everything else into
<the-rest>.  Separator is the IFS character.   Enjoy.


Quote:> I need to make a shell script that have to
> read a text file with recors , reading record by record
> and working with the info; but I don't know how to make
> a shell script read a text file, any clue ?

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


 
 
 

Record by record

Post by Willem Leene » Sun, 10 Sep 2000 17:52:58


man awk , the advanced command to do this sort of things.

> I need to make a shell script that have to
> read a text file with recors , reading record by record
> and working with the info; but I don't know how to make
> a shell script read a text file, any clue ?

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

 
 
 

Record by record

Post by David Hasset » Sun, 10 Sep 2000 22:49:03



> cat <filename> | while read <str1> <str2> <the-rest>
>     do
>     ...

>     ...
>     done

Better might be to use a redirection rather than 'cat':

  while read line; do
      set -- $line
      # print out first three records on each line
      echo $1 $2 $3
  done < filename

Cheers,

Dave. :-)

> - puts the first two fields into <str1> and <str2>, everything else into
> <the-rest>.  Separator is the IFS character.   Enjoy.


> > I need to make a shell script that have to
> > read a text file with recors , reading record by record
> > and working with the info; but I don't know how to make
> > a shell script read a text file, any clue ?

 
 
 

1. retrieve record from record file(binary) to output to disply, need help

Dear linux programmers(c/c++):

  I use following subsetion of my programs to try to retrieve the
record(some string variable cusnumber, from a record(binary) file,
but I get nothing (NULL of that string) at outfile(either display or
outfile)
I uses djgpp compiler with the book of c++(Liberty, sam , white) on
window98

  Please help, welcome any tech suggestions, sincere eric,

---------------------------------------------------------------------------

  ifstream CustomerInFile("CustomerFile.fil",ios::binary|ios::nocreate);

      // CustomerInFile.read((char  *) &customer, sizeof(customer));
    outfile.open("cusrep.txt");
        outfile << " Customer number, Customer name, Address, City,
State,dateofbirth, PhoneNumber, Balance\n";

        //while (  CustomerInFile.read((char  *) &customer, sizeof(customer))
        while ((CustomerInFile))
         {

                 CustomerInFile.read((char *) &customer, sizeof(customer));

                  //cout << " Customer number, Customer name, Address, City,
//State,dateofbirth, PhoneNumber, Balance\n";
                    *cusnumber = *customer.cusnumber;

CustomerInFile.get(cusnumber, 6);

         outfile  << customer.cusnumber;
         cout << cusnumber << "-------cusnumber\n";

2. WOW - This is Interesting

3. converting multi-line records to single line record

4. PPP and routing questions

5. Fixed length records containing 2 different records types with fixed field widths

6. Rolling my own keylogin for Solaris 2.4

7. Concatenating multiple records into a single record

8. XFS Oopses with 2.4.5 and 2.4.14?

9. Convert a big record into chunks of small records

10. dd: x records in and x records out

11. MX records and 2 A records to 1 ip? is that ok?

12. dig and nslookup don't report multiple cname records (nor multiple a records?) - Is there a tool which will?

13. HELP problem recording sound under Linux