Visit Our UNIX and Linux User Community

Top Forums Shell Programming and Scripting Problems with reg.-expressions in a awk-search-pattern Post 302808323 by IMPe on Thursday 16th of May 2013 12:32:04 PM
Old 05-16-2013
Problems with reg.-expressions in a awk-search-pattern


i have some problems with regular expressions in a awk search pattern.

what i want to do:
i want to calculate the mean-value in the time from 00:00 to 06:00

how my data looks like:
04/01/13-01:40  670992  54802   80711   116460  156177  
04/01/13-01:50  703725  60150   85498   118844  154391  
04/01/13-02:00  639716  54841   79710   112262  153321

what i tried so far:
i use the timestamp 04/01/13-hh:mm to filter my calculation.
the calc of the mean over the whole day works fine with
awk \04/01/13\ '{a+=$2} END{print a/NF}' file.txt

but when i try to extend the pattern like ..
awk \04/01/13-0[0-5]\ '{a+=$2} END{print a/NF}' file.txt

awk will crash.
can someone give me a hint please.

Thanks in advance!

Last edited by Scrutinizer; 05-16-2013 at 02:00 PM.. Reason: extra code tags for data sample
Test Your Knowledge in Computers #312
Difficulty: Easy
Linus Torvalds created Unix and Git.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

SCO vs Linux Reg Expressions Problem

Hi there, I'm investigating migrating a system currently running Scos osr5 to Linux (eg RH 7.2) but there are a lot of in house scripts, some of which are probably using "Sco specific" constructs etc. One I have come across is as follows, if ????? ] then ....etc.etc fi The regular... (2 Replies)
Discussion started by: pcs7088
2 Replies

2. Shell Programming and Scripting

Problems with regular expressions

Hi , I am reading data from a log file. The log file will be like this : 19:40:25 DEBUG : Failed xml-common.noarch 0-0.6.3-18 - u 19:40:25 ERROR : Batch failed 19:40:25 DEBUG : Batch exited with ERROR 104 19:40:25 ERROR : Batch exited with ERROR 105 19:40:25 DEBUG : Batch exited... (5 Replies)
Discussion started by: subin_bala
5 Replies

3. Shell Programming and Scripting

awk search pattern

Hi, I have a log file which contains lines like below: 2010-07-19 07:13:19,021 ERROR system ...(text) 2010-07-19 07:22:03,427 ERROR system ...(text) class com... (text) 2010-07-19 07:23:19,026 ERROR system ...(text) class com... (text) each line is a separate line... I am given the a... (14 Replies)
Discussion started by: a27wang
14 Replies

4. Shell Programming and Scripting

Reg expressions

Hi, I would like to grep for a string within a tag, can someone provide some assistance in how to do it? So I would like to use the grep command to find a string like: <tag>sometext<tag> because the sometext can be any number of characters or an type of number or lettering, what expression... (1 Reply)
Discussion started by: cyberfrog
1 Replies

5. Shell Programming and Scripting

Pattern Search using AWK

Hi All, I have the below file data.txt.Using awk i want to grep all the zone data.Form the below command i can extact data upto of zone i give but i want it should print until next pattern. awk '/^Total Collection /{c=5;next}c-->0' zin45srs08.tools_utilization instead of c=5 is it possible... (5 Replies)
Discussion started by: ajaincv
5 Replies

6. UNIX for Dummies Questions & Answers

Pattern search using awk

Hi All, I am trying to find numbers with balance greater than 1 and less than equal 2 from the below file using awk Input file num ,bal 100199,1.708 100225,0 100226,0 100228,0.771166 100232,2 output file 100199,1.708 100232,2 I am using the following command for this... (2 Replies)
Discussion started by: pistachio
2 Replies

7. Shell Programming and Scripting

Awk to match a pattern and perform a search after the first pattern

Hello Guyz I have been following this forum for a while and the solutions provided are super useful. I currently have a scenario where i need to search for a pattern and start searching by keeping the first pattern as a baseline ABC DEF LMN EFG HIJ LMN OPQ In the above text i need to... (8 Replies)
Discussion started by: RickCharles
8 Replies

8. Shell Programming and Scripting

Bash script - coloring reg. expressions in text

Hi all, is there anyone good at bash who will help me? I need to use syntax ${string/pattern/replacement} The problematic part where I am stuck is: #!bin/bash text="A cat is on a mat." exp="cat" newexp="SOMECODEcatSOMECODE" newtext=${${text}/${exp}/${newexp}} == > ERROR "wrong... (4 Replies)
Discussion started by: JohnnyM77
4 Replies

9. 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

10. Shell Programming and Scripting

Going mad on an egrep command (Reg Expressions)

Dear community, I am trying for several hours now to create an egrep command to grep the number of lines containing a specific text from a text-file but seem to have an error somewhere. The Textfile contains several thousand lines and has the expression "Lastname" in several lines.... (3 Replies)
Discussion started by: Donzo
3 Replies
Locale::Codes::LangFam(3)				User Contributed Perl Documentation				 Locale::Codes::LangFam(3)

Locale::Codes::LangFam - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangFam; $lext = code2langfam('apa'); # $lext gets 'Apache languages' $code = langfam2code('Apache languages'); # $code gets 'apa' @codes = all_langfam_codes(); @names = all_langfam_names(); DESCRIPTION
The "Locale::Codes::LangFam" module provides access to standard codes used for identifying language families, such as those as defined in ISO 639-5. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default ISO 639-5 language family codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language families. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langfam('apa','alpha'); $lext = code2langfam('apa',LOCALE_LANGFAM_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from ISO 639-5 such as 'apa' for Apache languages. This is the default code set. ROUTINES
code2langfam ( CODE [,CODESET] ) langfam2code ( NAME [,CODESET] ) langfam_code2code ( CODE ,CODESET ,CODESET2 ) all_langfam_codes ( [CODESET] ) all_langfam_names ( [CODESET] ) Locale::Codes::LangFam::rename_langfam ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangFam::add_langfam ( CODE ,NAME [,CODESET] ) Locale::Codes::LangFam::delete_langfam ( CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_alias ( NAME ,NEW_NAME ) Locale::Codes::LangFam::delete_langfam_alias ( NAME ) Locale::Codes::LangFam::rename_langfam_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::delete_langfam_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. ISO 639-5 . AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck ( COPYRIGHT
Copyright (c) 2011-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.3 2013-02-27 Locale::Codes::LangFam(3)

Featured Tech Videos

All times are GMT -4. The time now is 10:09 AM.
Unix & Linux Forums Content Copyright 1993-2021. All Rights Reserved.
Privacy Policy