1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

counting & printing record count

Discussion in 'Linux and Unix' started by grinder182533, Jan 13, 2011.

Thread Status:
Not open for further replies.
  1. grinder182533

    grinder182533 Thread Starter

    Joined:
    Jun 1, 2009
    Messages:
    72
    Hi
    I have a complex script which outputs a text file for loading to a db.
    I now need to enhance this script so that I can issue an ‘lp’ command
    to show the count of the number of records in this file.
    Can anybody give me the necessary syntax ?
    Many thanks in advance !
     
  2. maneetpuri

    maneetpuri

    Joined:
    Oct 14, 2008
    Messages:
    135
  3. lotuseclat79

    lotuseclat79

    Joined:
    Sep 12, 2003
    Messages:
    20,583
    Hi grinder182533,

    Correct me if I misunderstand your requirements, but lp only prints files, and if by the number of records in a "text file" you actually mean "the number of lines" in the text file, then you can issue the following command to count the number of lines in the file before you enter the text file as a data base entry:
    $ cat textfile | wc -l
    will count the number of lines in the textfile.

    Is the textfile you load into the db actually - one record - in the db? If that is the case, then ignore the above example as it will not give you the number of records in the db. For that you will have to look up the db documentation used by the data base administrator and issue one of the commands related to administering the db to find out that information.

    -- Tom
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/974407

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice