Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Pattern matching and Printing Filename Post 302336851 by krao on Thursday 23rd of July 2009 02:20:41 AM
Old 07-23-2009
Pattern matching and Printing Filename

Hi,

My requirement is to search for a paritcular string from a group of .gz files and to print the lines containing that string and the name of the files in which that string is present.

Daily 500 odd .gz files will be generated in a directory(directory name will be in the form of daymonthyear i.e 230709) in /data3/home path.
Means the mentioned path has many such directories with .gz files.

I used below command, it's printing the lines containing that string but not filename.


find /data3/home/ -type f -name 'TRCansLog*.gz' -exec gzcat *.gz {} \; | nawk '/xfvc010423465107/ {print $0"\t" FILENAME}'

Pls help me

If possible pls tell how to print the directory name in which the requried file and string present.


Thanks in advance
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Filename and Pattern matching

Hiiiii every one, I am facing a problem while giving a file name which has space in it. The problem is ... I have to read a file where the set of input files are stored. Now getting that name I have to open the file and i have to extract the name of the user from where it is written like"by... (2 Replies)
Discussion started by: kheyali Mitra
2 Replies

2. Shell Programming and Scripting

comment/delete a particular pattern starting from second line of the matching pattern

Hi, I have file 1.txt with following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 ** ** ** In file 2.txt I have the following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433... (4 Replies)
Discussion started by: imas
4 Replies

3. Shell Programming and Scripting

counting the lines matching a pattern, in between two pattern, and generate a tab

Hi all, I'm looking for some help. I have a file (very long) that is organized like below: >Cluster 0 0 283nt, >01_FRYJ6ZM12HMXZS... at +/99% 1 279nt, >01_FRYJ6ZM12HN12A... at +/99% 2 281nt, >01_FRYJ6ZM12HM4TS... at +/99% 3 283nt, >01_FRYJ6ZM12HM946... at +/99% 4 279nt,... (4 Replies)
Discussion started by: d.chauliac
4 Replies

4. UNIX for Advanced & Expert Users

fgrep - printing pattern and filename

Hi, I have a patternfile with following pattern cat dog cow pig Let's say I have thousand files file0001 file0002 file0003 . . . file1000 Each pattern can occur multiple times in multiple files. How can I search for pattern so the output of pattern and the filename is printed... (1 Reply)
Discussion started by: yoda9691
1 Replies

5. UNIX for Dummies Questions & Answers

Help with filename pattern matching

Hi, I have files in a directory with filenames that match three specific patterns: 1) *'.L2_LAC'* 2) *'.L2_LAC_OC'* 3) *'.L2_LAC_SST'* I would like to have an "ls" command that will list only files matching the first two patterns. However, if I type: ls *'.L2_LAC'* I will get files that... (2 Replies)
Discussion started by: msb65
2 Replies

6. Shell Programming and Scripting

Pattern Matching and printing

Dear All, I have a log file like below 13:26:31 |152.22 13:27:31 |154.25 13:28:31 |154.78 13:29:31 |151.23 13:30:31 |145.63 13:31:31 |142.10 13:32:31 |145.45 where values will be there from 00:00 hrs to 23:59 hrs. I'm matching for last occurance of 23:59 and printing 1440 lines (grep... (4 Replies)
Discussion started by: Naga06
4 Replies

7. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

8. Shell Programming and Scripting

Find: filename in every subdirectory matching a pattern

Hi, I have multiple directories built in following manner /app/red/tmp /app/blue/upd /app/blue/tmp /app/green/tmp /app/red/upd /app/green/upd I have filenames having pattern ONE.XXX.dat TWO.ZZZ.dat and so on across the folders listed above My objective is to list all filenames of a... (4 Replies)
Discussion started by: wahi80
4 Replies

9. Shell Programming and Scripting

UNIX awk pattern matching and printing lines

I have the below plain text file where i have some result, in order to mail that result in html table format I have written the below script and its working well. cat result.txt Page 2015-01-01 2000 Colors 2015-02-01 3000 Landing 2015-03-02 4000 #!/bin/sh LOG=/tmp/maillog.txt... (1 Reply)
Discussion started by: close2jay
1 Replies

10. Shell Programming and Scripting

Need help on pattern matching and printing the same

Hi, I need to match for the pattern '.py' in my file and print the word which contains. For example: cat testfile a b 3 4.py 5 6 a b.py c.py 4 5 6 7 8 1.py 2.py 3 4 5 6 Expected output: 4.py b.py c.py 1.py 2.py (3 Replies)
Discussion started by: Sumanthsv
3 Replies
Tcl_StringMatch(3)					      Tcl Library Procedures						Tcl_StringMatch(3)

__________________________________________________________________________________________________________________________________________________

NAME
Tcl_StringMatch, Tcl_StringCaseMatch - test whether a string matches a pattern SYNOPSIS
#include <tcl.h> int Tcl_StringMatch(str, pattern) int Tcl_StringCaseMatch(str, pattern, flags) ARGUMENTS
const char *str (in) String to test. const char *pattern (in) Pattern to match against string. May contain special characters from the set *?[]. int flags (in) OR-ed combination of match flags, currently only TCL_MATCH_NOCASE. 0 specifies a case-sensitive search. _________________________________________________________________ DESCRIPTION
This utility procedure determines whether a string matches a given pattern. If it does, then Tcl_StringMatch returns 1. Otherwise Tcl_StringMatch returns 0. The algorithm used for matching is the same algorithm used in the string match Tcl command and is similar to the algorithm used by the C-shell for file name matching; see the Tcl manual entry for details. In Tcl_StringCaseMatch, the algorithm is the same, but you have the option to make the matching case-insensitive. If you choose this (by passing TCL_MATCH_NOCASE), then the string and pattern are essentially matched in the lower case. KEYWORDS
match, pattern, string Tcl 8.5 Tcl_StringMatch(3)
All times are GMT -4. The time now is 04:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy