grep in unix version True 64


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers grep in unix version True 64
# 1  
Old 11-18-2007
grep in unix version True 64

Dear All

I have a unix version (True 64 ) and i want to grep some of data from zipping files with extention(.gz) altyhough i wouldn't to unzip these files, so can you help me grep these data in one command without unzip files.

Note:- In othe version of unix (i forget that version) i used the following command (zgrep -----) to grep data from zipping files.

So if you can help please advice.

thanks a lot.
# 2  
Old 11-18-2007
Actually zgrep is just a shell script wrapper around other utilities.

#!/bin/ksh

# zgrep -- a wrapper around a grep program that decompresses files as needed
# Adapted from a version sent by Charles Levert <charles@comm.polymtl.ca>

# Copyright (C) 1998, 2001, 2002, 2006, 2007 Free Software Foundation
# Copyright (C) 1993 Jean-loup Gailly

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

PATH=${GZIP_BINDIR-'/usr/local/bin'}:$PATH
grep='${GREP-grep}'

version='zgrep (gzip) 1.3.12
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software. You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.

Written by Jean-loup Gailly.'

usage="Usage: $0 [OPTION]... [-e] PATTERN [FILE]...
Look for instances of PATTERN in the input FILEs, using their
uncompressed contents if they are compressed.

OPTIONs are the same as for 'grep'.

Report bugs to <bug-gzip@gnu.org>."

# sed script to escape all ' for the shell, and then (to handle trailing
# newlines correctly) turn trailing X on last line into '.
escape='
s/'\''/'\''\\'\'''\''/g
$s/X$/'\''/
'
operands=
have_pat=0
files_with_matches=0
files_without_matches=0
no_filename=0
with_filename=0

while test $# -ne 0; do
option=$1
shift
optarg=

case $option in
(-[0123456789abcdhHiIKLlnoqrRsTuUvVwxyzZ]?*)
arg2=-\'$(expr "X${option}X" : 'X-.[0-9]*\(.*\)' | sed "$escape")
eval "set -- $arg2 "'${1+"$@"}'
option=$(expr "X$option" : 'X\(-.[0-9]*\)');;
(--binary-*=* | --[lm]a*=* | --reg*=*)
;;
(-[ABCDefm] | --binary-* | --file | --[lm]a* | --reg*)
case ${1?"$option option requires an argument"} in
(*\'*)
optarg=" '"$(printf '%sX\n' "$1" | sed "$escape");;
(*)
optarg=" '$1'";;
esac
shift;;
(--)
break;;
(-?*)
;;
(*)
case $option in
(*\'*)
operands="$operands '"$(printf '%sX\n' "$option" | sed "$escape");;
(*)
operands="$operands '$option'";;
esac
${POSIXLY_CORRECT+break}
continue;;
esac

case $option in
(-[drRzZ] | --di* | --exc* | --inc* | --rec* | --nu*)
printf >&2 '%s: %s: option not supported\n' "$0" "$option"
exit 2;;
(-[ef]* | --file | --file=* | --reg*)
have_pat=1;;
(--h | --he | --hel | --help)
echo "$usage" || exit 2
exit;;
(-H | --wi | --wit | --with | --with- | --with-f | --with-fi \
| --with-fil | --with-file | --with-filen | --with-filena | --with-filenam \
| --with-filename)
with_filename=1
continue;;
(-l | --files-with-*)
files_with_matches=1;;
(-L | --files-witho*)
files_without_matches=1;;
(--no-f*)
no_filename=1;;
(-V | --v | --ve | --ver | --vers | --versi | --versio | --version)
echo "$version" || exit 2
exit;;
esac

case $option in
(*\'?*)
option=\'$(expr "X${option}X" : 'X\(.*\)' | sed "$escape");;
(*)
option="'$option'";;
esac

grep="$grep $option$optarg"
done

eval "set -- $operands "'${1+"$@"}'

if test $have_pat -eq 0; then
case ${1?"missing pattern; try \`$0 --help' for help"} in
(*\'*)
grep="$grep -- '"$(printf '%sX\n' "$1" | sed "$escape");;
(*)
grep="$grep -- '$1'";;
esac
shift
fi

if test $# -eq 0; then
set -- -
fi

exec 3>&1
res=0

for i
do
# Fail if gzip or grep (or sed) fails.
gzip_status=$(
exec 5>&1
(gzip -cdfq -- "$i" 5>&-; echo $? >&5) 3>&- |
if test $files_with_matches -eq 1; then
eval "$grep" >/dev/null && { printf '%s\n' "$i" || exit 2; }
elif test $files_without_matches -eq 1; then
eval "$grep" >/dev/null || {
r=$?
if test $r -eq 1; then
printf '%s\n' "$i" || r=2
fi
exit $r
}
elif test $with_filename -eq 0 &&
{ test $# -eq 1 || test $no_filename -eq 1; }; then
eval "$grep"
else
case $i in
(*'
'* | *'&'* | *'\'* | *'|'*)
i=$(printf '%s\n' "$i" |
sed '
$!N
$s/[&\|]/\\&/g
$s/\n/\\n/g
');;
esac
sed_script="s|^|$i:|"

# Fail if grep or sed fails.
r=$(
exec 4>&1
(eval "$grep" 4>&-; echo $? >&4) 3>&- | sed "$sed_script" >&3 4>&-
) || r=2
exit $r
fi >&3 5>&-
)
r=$?
test "$gzip_status" -eq 0 || test "$gzip_status" -eq 2 || r=2
test $res -lt $r && res=$r
done
exit $res
# 3  
Old 11-18-2007
Will "gzcat file | grep ...." work?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Grep --byte-offset not returning the offset (Grep version 2.5.1)

Hi, I am trying to get the position of a repeated string in a line using grep -b -o "pattern" In my server I am using GNU grep version 2.14 and the code is working fine. However when I am deploying the same code in a different server which is using GNU grep version 2.5.1 the code is not... (3 Replies)
Discussion started by: Subhamoy
3 Replies

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

3. Solaris

Migrate unix version 8 to version 9

i have a program writing in PRO C which currently running in unix version 8 tie with oracle 8i, but in the future company gonna migrate this OS to version 9. Anything i have to prepare for my PRO C program to run in unix version 9? or anything would that impact my program couldn't run well? what... (2 Replies)
Discussion started by: lsy
2 Replies

4. UNIX for Dummies Questions & Answers

Which version of UNIX I'm using?

Hello- I know it's UNIX-HP, but I don't know what version. Is there a command that tells me what version I'm running or a file that I need to open to get this information? Thanks, Nomaad (1 Reply)
Discussion started by: Nomaad
1 Replies

5. UNIX for Dummies Questions & Answers

UNIX Version

Please post me a command, About how to find UNIX version on our machine. i have tried > WHICH Version it didn't worked though. (2 Replies)
Discussion started by: Kzar
2 Replies

6. Solaris

Installing True Type fonts on Unix - Please help

Hi to all, I have copied some true type fonts to my /usr/openwin/lib/X11/fonts/TrueType directory. I need to get the fonts.dir file updated. I have tried using the mkfontdir command but the file does not get updated with my new fonts. Can someone please help me as I have struggled with this... (3 Replies)
Discussion started by: montejr
3 Replies

7. UNIX Desktop Questions & Answers

TRUE Unix-64 Printer Driver for HP-6L laserjet.

Can anyone suggest me from where to download the printer driver for HP 6L laserjet printer for servers/desktops having TRUE Unix-64 and Unixware 7.0 OS. (1 Reply)
Discussion started by: parbende
1 Replies

8. Programming

C++ on True Unix Platform

Hi all: I would like to get some details about development using C++ on TRUE Unix platform. Can anyone help me ?? Thanks, -Mandar (2 Replies)
Discussion started by: mandar3
2 Replies

9. Where do I download LINUX & UNIX?

What version of Unix do you use most often?

Just curious... (1 Reply)
Discussion started by: PxT
1 Replies

10. UNIX for Dummies Questions & Answers

Which unix version...

I pulled out my old 386 from the garage and dusted it off, and now i want to install unix on it. The 386 however only has a 104mb HD, and has NO cd rom support. Which if any version of unix would best suite this box? Is installing with floppies my only option? (8 Replies)
Discussion started by: nefarious
8 Replies
Login or Register to Ask a Question