Find the answer to your Linux question:
Results 1 to 6 of 6
I have a very large flat file that I would like to copy but drop those records that have a field (like Positions 145 to 152) that is less than ...
  1. #1
    Just Joined!
    Join Date
    Jan 2009
    Posts
    3

    Question I need to drop records from afile.

    I have a very large flat file that I would like to copy but drop those records that have a field (like Positions 145 to 152) that is less than a certain Value. I've searched for tools, Unix/linux commands, etc, but I can not find a simple way to do this.

    Can someone help and point the way?

    Thanks in advance!

    Rock

  2. #2
    Just Joined!
    Join Date
    Jan 2009
    Posts
    15
    I am sorry, but could you try to explain that a little more clearly. A flat file? You mean as in a document, or do you mean a database file? In either case, if you are trying to move the file to a different location then you should be able to just right-click, copy/cut, and then paste to wherever. If the file is in a Root folder then you will need to be Root to access it.

  3. #3
    Just Joined!
    Join Date
    Jan 2009
    Posts
    3
    By flat file, I mean a series of fixed length text records. The file contains over 10 million records with a date in a certain location. I want to copy the file so that the new file will have only those records which have a date greater than "20080630" (YYYYMMDD). I need to do this to avoid space and performance issues.

    On the IBM Mainframes, there are some file processing/audit/reporting software packages like EasyTrieve and DYL-280. I was looking for a program that had some of the more basic features of those programs.

    Rock

  4. #4
    Just Joined!
    Join Date
    Jan 2009
    Posts
    15
    Sorry about that. I understand your question now, but I do not know what else you could use, or how you would even go about this. To get a proper answer to that question you might want to move your question to the Networking or Application part of this forum. That way you will get the attention of people on that level of understanding. Again, sorry about that, but the majority of my knowledge is limited to home computing, networking, and a little programming.

  5. #5
    Linux Engineer Freston's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    1,047
    Well, you could use a bash script to do that for you.

    Something to the effect of:

    Assuming the date is in the 145th position:
    Code:
    #!/bin/bash
    MINIMUMDATE="20080630"
    for i in `cat file` ; do
       DATETEST=`echo $i|awk '{print $145}'`
       if [ $DATETEST -ge $MINIMUMDATE ] ; then
          echo $i >> newfile
       fi
    done
    You should have all records with a date greater or equal to 30-06-2008 in a file called newfile.
    Can't tell an OS by it's GUI

  6. #6
    Just Joined!
    Join Date
    Jan 2009
    Posts
    3

    Smile

    Thank You CamoAnimal.

    I will try the script, but if I understand this, I believe that will do the trick.

    Rock

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...