Sponsored Content
Full Discussion: Ques
Top Forums Shell Programming and Scripting Ques Post 59003 by zazzybob on Tuesday 7th of December 2004 11:21:06 AM
Old 12-07-2004
Make sure you backslash escape the dot "." as it is a metacharacter (any char).

The code above will also match anything ending in an upper-case Z, e.g.

echo "something.ZAZZ" | grep '.Z$'
will match.

You need
echo "something.ZAZZ" | grep '\.Z$' (exit code 1)
echo "foo.log.Z" | grep '\.Z$' (exit code 0 - correct)

EDIT:

To get you on the right track. Let's assume you write a script, foo.sh. You call foo.sh something like this

$ ./foo.sh myfile

Where myfile can sometimes have a .Z extension.

Within your code, do something like (I've made this fairly verbose so you can see what's happening)

Code:
#!/bin/sh

inputfile=$1

echo "$inputfile" | grep '\.Z$' >/dev/null 2>&1
if [ "$?" -eq "0" ]; then
   # yay, it's been compressed
   zcat $inputfile | while read line
   do
     echo "Heres the line... $line"
   done
else
   # assume it's not compressed, you could check for .gz, etc
   while read line
   do
     echo "Heres the line... $line"
   done < $inputfile
fi

exit 0

This is untested, but should work.

Cheers
ZB

Last edited by zazzybob; 12-07-2004 at 12:31 PM..
 

5 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

ques regarding date command

i have couple of my assignment questions What command results in adding today's date and time to the file yesterday.txt What command results in creation of a new file named yesterday.txt that contains yesterday's date but no time (3 Replies)
Discussion started by: doomed47
3 Replies

2. Shell Programming and Scripting

Field separator Ques.

Hello... Im trying to use "- " as field separator... I used awk -F"- " '{print $3}' input_file ... but it's not working, it assumes that the field separator is "-" and not "- " ... Any ideas ?? :( Thanks (6 Replies)
Discussion started by: yahyaaa
6 Replies

3. UNIX for Dummies Questions & Answers

Fsck ques

hy guys I got a ques I cant acess root, i tried to fsck it, but gets errors to read file systems. What steps do you take to recover the host before you see if there is any data corruption on the root drive? Regards Charneet (1 Reply)
Discussion started by: charneet
1 Replies

4. UNIX for Dummies Questions & Answers

Service ques

hi, Can someone tell me what commands do you use to start service back upin solaris ? Regards Charneet (1 Reply)
Discussion started by: charneet
1 Replies

5. UNIX for Advanced & Expert Users

UNIX ques!! Ans URGENT!!

hello guys!! need 1 favour from u all.. Can u jst tell me the answers for these ques?? 1. ls - l _____ : command to return all files that end with single digit and those with TXT extension 2. ls -l report* _______ : command to return all files that start with the word RPT except those with LOG... (1 Reply)
Discussion started by: Gan_7
1 Replies
uudemon(4)						     Kernel Interfaces Manual							uudemon(4)

NAME
uudemon.admin, uudemon.cleanu, uudemon.hour, uudemon.poll - Administrative shell scripts for polling remote systems, cleaning up spool directories, reporting status to the system administrator, and routine invocations of the uuxqt and uusched daemons SYNOPSIS
These shell scripts reside in the following directory: /usr/lib/uucp DESCRIPTION
All the scripts can be run from the command line or can be run automatically by the cron daemon. To automatically run the scripts, remove the comment character (#) from the beginning of the relevant line in the /var/spool/cron/crontabs/uucp file. This script reports status to the system administrator. It issues the uustat command to find out the status of uucp jobs. It mails the results to the uucp login ID. The script may be modified to send mail to any login ID such as the uucp administrative login ID (uucpa) or root. This script cleans up the /var/spool/uucp and /var/spool/uucppublic directories by running the uucleanup command. The uucleanup com- mand is run with the following parameters: -C7, -D7, X2, -o2, -W1. This script runs the uusched and uuxqt daemons in the background. This script polls the systems listed in the /usr/lib/uucp/Poll file. The uudemon.poll script should be scheduled before the uudemon.hour script. This allows uudemon.poll to create any command files before cron runs the uudemon.hour script. FILES
Contains the uudemon.admin, uudemon.cleanu, uudemon.hour and uudemon.poll files. Contains the uucp file. RELATED INFORMATION
Commands: cron(8), uucleanup(8), uusched(8), uuxqt(1) Files: /usr/lib/uucp delim off uudemon(4)
All times are GMT -4. The time now is 05:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy