Sponsored Content
Top Forums Shell Programming and Scripting Bash to verify each line in input for specific pattern Post 302997619 by RavinderSingh13 on Wednesday 17th of May 2017 11:10:39 AM
Old 05-17-2017
Hello cmccabe,

Still not 100% sure, could you please try following and let me know if this helps you.
Code:
awk 'FNR==1 && /found expected header/{VAL++} FNR==2 && /found expected order of fields/{VAL++} FNR==3 && /R_Index is a number/{VAL++} FNR==4 && /PopFreqMax is valid/{VAL++} FNR==5 && /Quality is a character/{VAL++} FNR==6 && /HGMD and Sanger are valid/{VAL++} END{if(VAL==6){print FILENAME " is verified."}}'  Input_file*

You could mention in above as file* if you have only files with digits in them else you could change the regex to file[0-9] etc depending upon your files.
EDIT: Adding a non-one liner for of solution too successfully now.
Code:
awk 'FNR==1 && /found expected header/{
                                        VAL++
                                     }
     FNR==2 && /found expected order of fields/{
                                                VAL++
                                              }
     FNR==3 && /R_Index is a number/{
                                        VAL++
                                   }
     FNR==4 && /PopFreqMax is valid/{
                                        VAL++
                                   }
     FNR==5 && /Quality is a character/{
                                        VAL++
                                      }
     FNR==6 && /HGMD and Sanger are valid/{
                                                VAL++
                                         }
     END{
                if(VAL==6){
                                print FILENAME " is verified."
                          }
        }
    '   Input_file

Thanks,
R. Singh

Last edited by RavinderSingh13; 05-17-2017 at 12:33 PM..
This User Gave Thanks to RavinderSingh13 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

merge columns into one line after a specific pattern

Hi all, im a linux newbie, plz help! I have a file - box -------- Fox-2 -------- UF29 zip42 -------- zf-CW SNF2_N Heli_Z -------- Fox -------- Kel_1 box (3 Replies)
Discussion started by: sam_2921
3 Replies

2. Shell Programming and Scripting

Bash Script verify user input is not empty and is equal to a value

I need to create a script that has a user enter a value. I want to verify that the value is either 1,2, or 3. If it is not then I want them to try entering it again. I am using a while loop to force them to retry. I am able to test the input against 1,2, and 3, but when I test agains an... (4 Replies)
Discussion started by: spartiati
4 Replies

3. Shell Programming and Scripting

Added new line before a specific pattern problem asking

Input file: Sample1 Type pattern 842 3150 Sample1 Type range 842 3150 Sample1 Type pattern 842 1127 Sample1 Type option 842 1127 Sample1 Type length 1483 1603 Sample1 Type pattern 1483 1603 Sample1 Type length 1698 1747 Sample1 Type option 1698 1747 Sample1 Type length 1868 1935 Sample1... (13 Replies)
Discussion started by: patrick87
13 Replies

4. Programming

Print specific pattern line in c++

Input file: @HWI-BRUNOP1_header_1 GACCAATAAGTGATGATTGAATCGCGAGTGCTCGGCAGATTGCGATAAAC +HWI-BRUNOP1_header_1 TNTTJTTTETceJSP__VRJea`_NfcefbWe Desired output file: >HWI-BRUNOP1_header_1 GACCAATAAGTGATGATTGAATCGCGAGTGCTCGGCAGATTGCGATAAAC >HWI-BRUNOP1_header_2... (10 Replies)
Discussion started by: cpp_beginner
10 Replies

5. Shell Programming and Scripting

Insert new pattern in newline after the nth occurrence of a line pattern - Bash in Ubuntu 12.04

Hi, I am getting crazy after days on looking at it: Bash in Ubuntu 12.04.1 I want to do this: pattern="system /path1/file1 file1" new_pattern=" data /path2/file2 file2" file to edit: data.db - I need to search in the file data.db for the nth occurrence of pattern - pattern must... (14 Replies)
Discussion started by: Phil3759
14 Replies

6. Shell Programming and Scripting

Help to just print out specific line from an input file

Hi, I have a file which contains 2,500,500,432 lines. Can I know what command I should type in order just print out particular line from the input file? eg. I just wanna to see what is the contents at line 522,484,612. Thanks for advice. (3 Replies)
Discussion started by: perl_beginner
3 Replies

7. Shell Programming and Scripting

Replace string in line below specific pattern?

Hi, I'm trying to replace a string with sed, in a text file containing this pattern: location alpha value x location beta value y location gamma value y location delta value y location theta value z ... What I want to achieve is: Find location beta into text file... (1 Reply)
Discussion started by: TECK
1 Replies

8. Shell Programming and Scripting

Replace the line with specific pattern

Hello All I'm trying to change one string from a file contening this patern: xxxx-xxxx 4 numbers - end 4 other numbers This is a sample of the file: LDR 00679 am a2200205 4500 =001 3617 =008 030219s2000\\\\xxx|||||\||||\00|\0\spa\d =020 \\$a0211-1942 =041 \\$aCastellà =093 ... (5 Replies)
Discussion started by: ldiaz2106
5 Replies

9. Shell Programming and Scripting

Extract specific line in an html file starting and ending with specific pattern to a text file

Hi This is my first post and I'm just a beginner. So please be nice to me. I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file? I have tried sed -n 241,241p... (13 Replies)
Discussion started by: dejavo
13 Replies

10. Shell Programming and Scripting

Need to cut a specific pattern from a line

Hello, I need to cut a specific pattern from a line irrespecitve of knowing field place. I am aware to cut field if you know the place of the field, but for me The sting place varies. 1468129514436,0,something_error,Non HTTP response code: java.net.URISyntaxException,Non HTTP response... (5 Replies)
Discussion started by: mirwasim
5 Replies
LIBBASH(7)							  libbash Manual							LIBBASH(7)

NAME
libbash -- A bash shared libraries package. DESCRIPTION
libbash is a package that enables bash dynamic-like shared libraries. Actually its a tool for managing bash scripts whose functions you may want to load and use in scripts of your own. It contains a 'dynamic loader' for the shared libraries ( ldbash(1)), a configuration tool (ldbashconfig(8)), and some libraries. Using ldbash(1) you are able to load loadable bash libraries, such as getopts(1) and hashstash(1). A bash shared library that can be loaded using ldbash(1) must answer 4 requirments: 1. It must be installed in $LIBBASH_PREFIX/lib/bash (default is /usr/lib/bash). 2. It must contain a line that begins with '#EXPORT='. That line will contain (after the '=') a list of functions that the library exports. I.e. all the function that will be usable after loading that library will be listed in that line. 3. It must contain a line that begins with '#REQUIRE='. That line will contain (after the '=') a list of bash libraries that are required for our library. I.e. every bash library that is in use in our bash library must be listed there. 4. The library must be listed (For more information, see ldbashconfig(8)). Basic guidelines for writing library of your own: 1. Be aware, that your library will be actually sourced. So, basically, it should contain (i.e define) only functions. 2. Try to declare all variables intended for internal use as local. 3. Global variables and functions that are intended for internal use (i.e are not defined in '#EXPORT=') should begin with: __<library_name>_ For example, internal function myfoosort of hashstash library should be named as __hashstash_myfoosort This helps to avoid conflicts in global name space when using libraries that come from different vendors. 4. See html manual for full version of this guide. AUTHORS
Hai Zaar <haizaar@haizaar.com> Gil Ran <ril@ran4.net> SEE ALSO
ldbash(1), ldbashconfig(8), getopts(1), hashstash(1) colors(1) messages(1) urlcoding(1) locks(1) Linux Epoch Linux
All times are GMT -4. The time now is 07:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy