Visit Our UNIX and Linux User Community

Top Forums Shell Programming and Scripting Problems with reg.-expressions in a awk-search-pattern Post 302808329 by Corona688 on Thursday 16th of May 2013 12:43:23 PM
Old 05-16-2013
What do you mean 'awk will crash'?

I'm amazed these worked either way honestly -- you can't have code outside the quote like that...

awk '/04\/01\/13-0[0-5]/ { a+=$2 ; b++ } END { print a/b }' file.txt

This User Gave Thanks to Corona688 For This Post:
Test Your Knowledge in Computers #66
Difficulty: Medium
IT and cybersecurity risk management is based on the intersection of these three areas, criticality, vulnerability, and threat.
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

mb_ereg_search_init - Setup string and regular expression for a multibyte regular expression match

bool mb_ereg_search_init (string $string, [string $pattern], [string $option = "msr"]) DESCRIPTION
mb_ereg_search_init(3) sets $string and $pattern for a multibyte regular expression. These values are used for mb_ereg_search(3), mb_ereg_search_pos(3), and mb_ereg_search_regs(3). PARAMETERS
o $string - The search string. o $pattern - The search pattern. o $option - The search option. RETURN VALUES
Returns TRUE on success or FALSE on failure. NOTES
Note The internal encoding or the character encoding specified by mb_regex_encoding(3) will be used as the character encoding for this function. SEE ALSO
mb_regex_encoding(3), mb_ereg_search_regs(3). PHP Documentation Group MB_EREG_SEARCH_INIT(3)

Featured Tech Videos

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