Sponsored Content
Full Discussion: Checking a file
Top Forums Shell Programming and Scripting Checking a file Post 302379157 by m1xram on Wednesday 9th of December 2009 05:29:48 PM
Old 12-09-2009
AWK with State Processing

Following code tries to do simple state processing but the '%(' and '%)' are used in two contexts so it has to skip possible errors for those lines. It is possible to improve the state processing if needed.
Code:
awk -f test4.awk input4.txt

You could also pass in the 'delta' value on the command line. To do so, remove the delta assignment in the BEGIN block and use '-d delta=40' on the command line.
Code:
# File: test4.awk
BEGIN {
      state = 0;
      delta = 40;
}

/^[0-9]/ {
      if (state == 2) {
        if ($2 == 0 && $3 == 0) {
          printf("Info: Zeros found for %d, at line %d.\n", $1, FNR);
        }
        if (prev != -9999) {
          if (($1 - prev) > delta) {
            printf("Error: Sequence delta of %d exceeded, at line %d.\n", delta, FNR);
          }
        }
        prev = $1
      }
}

/%</ {
      if (state != 0) {
        printf("Error: wrong state %d, line %d.\n", state, FNR);
        exit;
      }
      state = 1;
      sourcen = $2;
      sourcev = $3;
}

/%\(/ {
      if (state == 1) {
        state = 2;
        phasen = $2;
        phasev = $3;
        prev = -9999;
        printf("Info: Processing %s %d: %s %d.\n", sourcen, sourcev,
           phasen, phasev);
      }
}

/%\)/ {
      if (state == 2) {
        state = 1;
      }
}

/%>/ {
      if (state != 1) {
        printf("Error: wrong state %d, line %d.\n", state, FNR);
        exit;
      }
      state = 0;
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error checking a file from previous file size

Hi, I'm currently trying to write a script that checks a log file for certain errors. Once checked it then records the filesize in another file. All this is fine, my problem is that the next time I do my error check I only want to check from previously recorded filesize to the end of file. I'm... (2 Replies)
Discussion started by: stuck1
2 Replies

2. Shell Programming and Scripting

Multiple file existence and checking file size

I want to check the files in particular directory are more that 0 Bytes i.e, Non zero byte file. The script should print a msg if all the files in that directory are empty( 0 Byte). (2 Replies)
Discussion started by: lathish
2 Replies

3. Shell Programming and Scripting

Checking for a control file before processing a data file

Hi All, I am very new to Shell scripting... I got a requirement. I will have few text files(data files) in a particular directory. they will be with .txt extension. With same name, but with a different extension control files also will be there. For example, Sample_20081001.txt is the data... (4 Replies)
Discussion started by: purna.cherukuri
4 Replies

4. Shell Programming and Scripting

file checking

Hi I need to check the file,if file exist ,do some other opearations and make it successful. If file does not exist skip all steaps,go to last step and make it succesful.below is scripts is working for file exist but its not working for file not exist ... (0 Replies)
Discussion started by: mohan705
0 Replies

5. Shell Programming and Scripting

Script check for file, alert if not there, and continue checking until file arrives

All, Is there a way to keep checking for a file over and over again in the same script for an interval of time? Ie If { mail -user continue checking until file arrives file arrives tasks exit I don't want the script to run each time and email the user each time a file... (4 Replies)
Discussion started by: markdjones82
4 Replies

6. UNIX for Dummies Questions & Answers

Checking for same file name

I was wondering if there is a way to to check if two files are the same. I've tried writing a script called samefile, which takes in two arguments (files) and attempts to compare them to see if they're the same file. Here is what I have so far: if then echo "The two files are not the... (4 Replies)
Discussion started by: Trinimini
4 Replies

7. UNIX for Advanced & Expert Users

File checking

Hello Experts, File contains 5 columns with | delimeter. 1,3,5 columns are required columns means it should contains values. reset of the columns it will contain value or not. test1.txt: Code: a@a.com|a|b|c|d |a|b|c|d output: test2.txt Code: a@a.com|a|b|c|d I need the unix... (1 Reply)
Discussion started by: muralikri
1 Replies

8. Shell Programming and Scripting

File checking

Hello Experts, File contains 5 columns with | delimeter. 1,3,5 columns are required columns means it should contains values. reset of the columns it will contain value or not. test1.txt: a@a.com|a|b|c|d |a|b|c|d output: test2.txt a@a.com|a|b|c|d I need the unix script, read the... (5 Replies)
Discussion started by: muralikri
5 Replies

9. Shell Programming and Scripting

Awk: File Checking Issues with 9 multiple file

Hi, I have 9 files which are generated dynamically & if there is a some condition which doesn't meet the criteria then file is not created or is of zero size. so further i am unable to consolidate the files based on following code 1 awk -F, -v ptime="201407" 'FNR==1... (3 Replies)
Discussion started by: siramitsharma
3 Replies

10. Shell Programming and Scripting

Checking Multiple File existance in a UNIX folder(Note: File names are all different)

HI Guys, I have some 8 files with different name and extensions. I need to check if they are present in a specific folder or not and also want that script to show me which all are not present. I can write if condition for each file but from a developer perspective , i feel that is not a good... (3 Replies)
Discussion started by: shankarpanda003
3 Replies
rmdel(1)						      General Commands Manual							  rmdel(1)

NAME
rmdel - remove a delta from an SCCS file SYNOPSIS
SID file ... DESCRIPTION
The command removes the delta specified by the SID from each named SCCS file. The delta to be removed must be the newest (most recent) delta in its branch in the delta chain of each named SCCS file. In addition, the SID specified must be that of a version being edited for the purpose of making a delta (i.e., if a p-file (see get(1)) exists for the named SCCS file, the SID specified must appear in any entry of the p-file). If a directory is named, behaves as though each file in the directory were specified as a named file, except that non-SCCS files (last com- ponent of the path name does not begin with and unreadable files are silently ignored. If a name of is given, the standard input is read; each line of the standard input is taken to be the name of an SCCS file or directory to be processed; non-SCCS files and unreadable files are silently ignored. When is specified on the command line, all following arguments are treated as file names. The permissions to remove a delta are either (1) if you make a delta you can remove it; or (2) if you own the file and directory you can remove a delta. EXTERNAL INFLUENCES
Environment Variables determines the locale for the interpretation of text as single-byte and/or multi-byte characters. determines the language in which messages are displayed. also determines the local language equivalent of the affirmative string ("yes"). If or is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty variable. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to "C". See environ(5). International Code Set Support Single-byte and multi-byte character code sets are supported. DIAGNOSTICS
Use sccshelp(1) for explanations. FILES
See delta(1). See delta(1). SEE ALSO
delta(1), get(1), sccshelp(1), prs(1), sccsfile(4). STANDARDS CONFORMANCE
rmdel(1)
All times are GMT -4. The time now is 03:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy