Sponsored Content
Top Forums Shell Programming and Scripting Awk search for string pattern in delimited file Post 302442770 by Franklin52 on Thursday 5th of August 2010 11:42:52 AM
Old 08-05-2010
Quote:
Originally Posted by alienated
Thank you for your prompt reply.

I wish to perform some additional functions in your current command. I would like to get the key and value pair.

Code:
FS="="  
split($i, MTH)
key = MTH[1]
value = MTH[2]

FS="/" # if there is no / separator, can I just check the value?
split($value, MTHCHECK)
oldmth=value[1]
newmth=value[2]
# if the value is null -z just skip the check
if oldmth > "12" print "invalid mth" 
if oldmth > "0" && < "13" print "valid mth"
if newmth> "12" print "invalid mth" 
if newmth > "0" && < "13" print "valid mth"

How do i incorporate all this into an awk command? I am using bash by the way. Thanks again.
The awk command gives the output as you desire in your first post.

Can you post the exact desired output from the given log file?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search Mulitiple String pattern in a file

Hi, I need to search for a multiple string pattern(5 key words) in a file(similar to a flat file) ,and i need to store the output in a another file . In that file we may have mutiple occurrences of the key words.and i need only the unique. kindly help out. Thanks, Mohana Krishnan (2 Replies)
Discussion started by: krishnan_6015@y
2 Replies

2. UNIX for Dummies Questions & Answers

Trim String in 3rd Column in Tab Delimited File...SED/PERL/AWK?

Hey Everybody, I am having much trouble figuring this out, as I am not really a programmer..:mad: Datafile.txt Column0 Column1 Column2 ABC DEF xxxGHI I am running using WGET on a cronjob to grab a datafile, but I need to cut the first three characters from... (6 Replies)
Discussion started by: rickdini
6 Replies

3. UNIX for Dummies Questions & Answers

Search and replace string only in a particular column in a delimited file

I have file with multiple columns. Column values for a record may be same. Now i have to replace a column value(this can be same for the other columns) with new value. File.txt A,B,C,D,A,B,C,D,A,B,C,D A,B,C,D,A,B,C,D,A,B,C,D A,B,C,D,A,B,C,D,A,B,C,D A,B,C,D,A,B,C,D,A,B,C,D... (1 Reply)
Discussion started by: ksailesh
1 Replies

4. Shell Programming and Scripting

Help needed :Search and Replace a string pattern with empty in an xml file in unix

Search and Replace a string pattern with empty in an xml file in unix: My xml file would be like this : <Accounts><Name>Harish</Name><mobile>90844444444444445999 </mobile><TRIG>srcujim-1</TRIG></Accounts><Accounts><Name>Satish</Name><mobile>908999</mobile><TRIG>ettertrtt-1</TRIG></Accounts> ... (1 Reply)
Discussion started by: harish_s_ampeo
1 Replies

5. Shell Programming and Scripting

awk get search pattern from a file.

Here Is a problem I am facing with awk. Query --> I want to search for a string in a file and print next 15 lines below the matched string. 1.We do not have GNU grep so cannot use grep -A or grep -B commands. 2. Instead of passing the search pattern as a string to awk. I want the awk to... (4 Replies)
Discussion started by: togotutor
4 Replies

6. Shell Programming and Scripting

Search for a pattern in a String file and count the occurance of each pattern

I am trying to search a file for a patterns ERR- in a file and return a count for each of the error reported Input file is a free flowing file without any format example of output ERR-00001=5 .... ERR-01010=10 ..... ERR-99999=10 (4 Replies)
Discussion started by: swayam123
4 Replies

7. Shell Programming and Scripting

awk read one delimited file, search another delimited file

Hello folks, I have another doozy. I have two files. The first file has four fields in it. These four fields map to different locations in my second file. What I want to do is read the master file (file 2 - 23 fields) and compare each line against each record in file 1. If I get a match in all four... (4 Replies)
Discussion started by: dagamier
4 Replies

8. Shell Programming and Scripting

How can I use find command to search string/pattern in a file recursively?

Hi, How can I use find command to search string/pattern in a file recursively? What I tried: find . -type f -exec cat {} | grep "make" \; Output: grep: find: ;: No such file or directory missing argument to `-exec' And this: find . -type f -exec cat {} \; -exec grep "make" {} \;... (12 Replies)
Discussion started by: cola
12 Replies

9. UNIX for Beginners Questions & Answers

Search a string inside a pattern matched block of a file

How to grep for searching a string within a begin and end pattern of a file. Sent from my Redmi 3S using Tapatalk (8 Replies)
Discussion started by: Baishali
8 Replies

10. UNIX for Beginners Questions & Answers

Grep/awk using a begin search pattern and end search pattern

I have this fileA TEST FILE ABC this file contains ABC; TEST FILE DGHT this file contains DGHT; TEST FILE 123 this file contains ABC, this file contains DEF, this file contains XYZ, this file contains KLM ; I want to have a fileZ that has only (begin search pattern for will be... (2 Replies)
Discussion started by: vbabz
2 Replies
MIDI2LY(1)							   User Commands							MIDI2LY(1)

NAME
midi2ly - manual page for midi2ly (LilyPond) 2.14.2 SYNOPSIS
midi2ly [OPTION]... FILE DESCRIPTION
Convert MIDI to LilyPond input. OPTIONS
-a, --absolute-pitches print absolute pitches -d, --duration-quant=DUR quantise note durations on DUR -D, --debug debug printing -e, --explicit-durations print explicit durations -h, --help show this help and exit -i, --include-header=FILE prepend FILE to output -k, --key=ALT[:MINOR] set key: ALT=+sharps|-flats; MINOR=1 -o, --output=FILE write output to FILE -p, --preview preview of first 4 bars -s, --start-quant=DUR quantise note starts on DUR -S, --skip use s instead of r for rests -t, --allow-tuplet=DUR*NUM/DEN allow tuplet durations DUR*NUM/DEN -V, --verbose be verbose --version show version number and exit -w, --warranty show warranty and copyright -x, --text-lyrics treat every text as a lyric EXAMPLES
$ midi2ly --key=-2:1 --duration-quant=32 --allow-tuplet=4*2/3 --allow-tuplet=2*4/3 foo.midi REPORTING BUGS
Report bugs via http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs SEE ALSO
The full documentation for midi2ly is maintained as a Texinfo manual. If the info and midi2ly programs are properly installed at your site, the command info midi2ly should give you access to the complete manual. midi2ly (LilyPond) 2.14.2 February 2013 MIDI2LY(1)
All times are GMT -4. The time now is 12:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy