Should pick latest file within past 3 days using UNIX script and perform steps in message below.

Hi Chublar,

Thank you!My requirement is to pick and process the latest file received in past 3 days, which has ' SAMPLE ' in position 31 on line 19 and than grep ' GENERIC ' in the file and copying it to other file.

Instead of appending the ' GENERIC ' text from all the files.Can we just only process the latest file which has ' SAMPLE ' ?

operating system is windows 7 32 bit.
shell: /bin/bash
.dat file is : fixed width

Hi Don,

where does this length restriction come from? I'm not aware that there would be any general maximum line length for text files. Of course different applications may define their own limits. Solaris awk had for instance a limit of 2559 characters.

Ronald

Hi Ronald,
The definition of the term "Text File" in section 3.403 of the Base Definitions Volume of the 2008 revision of the IEEE Std 1003.1 (POSIX standard), The Open Group's Single UNIX Specification, and ISO/IEC Standard 9945-1 is:

The minimum value allowed by the standards for the LINE_MAX limit is 2048. I have yet to see an implementation that is shipped with LINE_MAX set to any value larger than 2048.

Many utilities that are defined by the standards to work on text files continue to work properly even if lines contain more than LINE_MAX bytes, contain NUL bytes, and/or have a final line that does not end with a <newline> character. But, if any of these happen on a particular input file the behavior of that utility is likely to vary from system to system in ways that may not be obvious, may ignore some parts of the file, and do so without indicating that any error has occurred.

We still do not have any clear description of what you are trying to do!

We now know that each of your .dat files has the same number of bytes, but we have no idea how to determine where line 19 in that file starts or ends. And, even if we did know how to identify the line boundaries on the 1st 19 lines, which file you want to process is not clear either.

Do you want to process the latest file? Or, do you want to process the latest file only if that file that contains SAMPLE (which has now apparently changed from S A M P L E ) starting at character position 31 on line 19? Or, do you want to process the latest file that contains SAMPLE or S A M P L E on line 19 starting at character position 31, and also contains at least once occurrence of GENERIC ?