Sponsored Content
Full Discussion: gzcat/grep
Top Forums Shell Programming and Scripting gzcat/grep Post 302328437 by tushar_tus on Wednesday 24th of June 2009 10:17:04 AM
Old 06-24-2009
gzcat/grep

Hi!!!

I am trying to grep a number in more then 1000 files which are .gz.
Below is the code :-


Code:
for i in `ls 20090618yz*_07.znf.gz`
do
a=`gzcat 20090618yz*_07.znf.gz | grep 9814843011`
if [ -n "$a" ]
then
echo $i 
fi
done

My objective is to echo the file name also with the data.

Please help!!!!
Thanks in advance....

Last edited by vidyadhar85; 06-24-2009 at 11:24 AM.. Reason: CODE TAGS ADDED
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

gzcat (or gunzip -c)

Does anyone know what kind of impact gunzip -c or gzcat has on a system? I am using gunzip -c on files that around 30 Mb compressed and 300Mb uncompressed. How much memory or disk space gets used? Also does anyone know how gunzip -c actually works? The system I am running on is AIX Version 5. ... (1 Reply)
Discussion started by: windjunky
1 Replies

2. Shell Programming and Scripting

gzcat into awk and then change FILENAME and process new FILENAME

I am trying to write a script that prompts users for date and time, then process the gzip file into awk. During the ksh part of the script another file is created and needs to be processed with a different set of pattern matches then I need to combine the two in the end. I'm stuck at the part... (6 Replies)
Discussion started by: timj123
6 Replies

3. Shell Programming and Scripting

MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else

Hi Guys, I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys. MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' ` Harby. (4 Replies)
Discussion started by: hariza
4 Replies

4. Shell Programming and Scripting

performance issue using gzcat, awk and sort

hi all, I was able to do a script to gather a few files and sort them. here it is: #!/usr/bin/ksh ls *mainFile* |cut -c20-21 | sort > temp set -A line_array i=0 file_name='temp' while read file_line do line_array=${file_line} let i=${i}+1 (5 Replies)
Discussion started by: naoseionome
5 Replies

5. UNIX for Dummies Questions & Answers

How to list file names instead of lines when grep a gzcat command?

Hi, I want to list filenames instead of lines when i search in compresed files for a string. #gzcat *.gz | grep -l 12345 gives me: <stdin> Anyone got a solution on this problem? (2 Replies)
Discussion started by: HugoH
2 Replies

6. UNIX for Dummies Questions & Answers

| help | unix | grep (GNU grep) 2.5.1 | advanced regex syntax

Hello, I'm working on unix with grep (GNU grep) 2.5.1. I'm going through some of the newer regex syntax using Regular Expression Reference - Advanced Syntax a guide. ls -aLl /bin | grep "\(x\)" Which works, just highlights 'x' where ever, when ever. I'm trying to to get (?:) to work but... (4 Replies)
Discussion started by: MykC
4 Replies

7. Shell Programming and Scripting

[Solved] Read a .gz file line by line without using gzcat

Hi all Is there a way to read and process a gzip file line by line similar to a text file without using gzcat.. while processing a text file we will usually use the logic exec<sample.txt while read line do echo $line done Is there a similar way to process the gz file in the same... (4 Replies)
Discussion started by: aikhaman
4 Replies

8. UNIX for Dummies Questions & Answers

gzcat help

Hi, I am using under-noted script and getting the error as under. Please help. Executing each individual cat / gzcat gives correct answer. gzcat /logs/1205* gzcat /logs/12052* cat /logs/12052 | egrep -v "XYZ|PQR"|wc -l gzcat: gzcat.gz: No such file or directory gzcat: cat.gz: No such... (2 Replies)
Discussion started by: vanand420
2 Replies

9. Shell Programming and Scripting

gzcat number of records

Hey guys, I want to do something quite simple but I just can't no matter what I try. I have a large file and i usually just: gzcat test.gz | nohup /test/this-script-does-things-to-the-records.pl -> /testdir/tmp_test.txt But now I need to do it only for the first 100k records. I sure... (7 Replies)
Discussion started by: sg3
7 Replies

10. Shell Programming and Scripting

Inconsistent `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`

i have this line of code that looks for the same file if it is currently running and returns the count. `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l` basically it is assigned to a variable ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies
ZGREP(1)						      General Commands Manual							  ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 02:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy