Sponsored Content
Full Discussion: grep from a script...
Top Forums UNIX for Advanced & Expert Users grep from a script... Post 80930 by zazzybob on Sunday 14th of August 2005 04:24:19 AM
Old 08-14-2005
Works fine for me....
Code:
$ cat > hamsasal.sh
for tim in "2005:00:" "2005:01:" "2005:02:" "2005:03:" "2005:04:" "2005:05:"; do
FormString="$tim"
echo "grep '$FormString' access.10Aug-1201AM"
count=`grep "$FormString" access.10Aug-1201AM | wc -l`
echo " Time : $tim Count : $count"
done
$ vi access.10Aug-1201AM
$ chmod +x ./hamsasal.sh
$ ./hamsasal.sh
grep '2005:00:' access.10Aug-1201AM
 Time : 2005:00: Count : 1
grep '2005:01:' access.10Aug-1201AM
 Time : 2005:01: Count : 1
grep '2005:02:' access.10Aug-1201AM
 Time : 2005:02: Count : 0
grep '2005:03:' access.10Aug-1201AM
 Time : 2005:03: Count : 0
grep '2005:04:' access.10Aug-1201AM
 Time : 2005:04: Count : 0
grep '2005:05:' access.10Aug-1201AM
 Time : 2005:05: Count : 0

Is your script located in the same directory as the files you're processing? If not, then it won't be able to open them as you are not specifying the full path to the file.

Either specify the full path, or add a line before the for loop cd'ing into the appropriate directory.

Cheers
ZB
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

grep script

hi guys, i was hoping you could help me out with the following im designing a help site for my work colleagues and would like a little script which would do a grep to check if an application is running on unix for example this is what i do on unix ps -ef | grep mqm and this tells me if... (4 Replies)
Discussion started by: drchris
4 Replies

2. Shell Programming and Scripting

Grep within a script

Hi, I am new to this - I have a unix command (below) that I would like to make automated. I would like the script to run the below command line but would like user input for '\' and '\' as these values will change depending on what i'm searching for. Is this possible? if so please help. ... (13 Replies)
Discussion started by: dnash
13 Replies

3. UNIX for Dummies Questions & Answers

trying to grep the first few lines of a continuos script, and exit the script anyidea

Hi. I am trying to extract the output of the first few lines of a continuos sh script. The when i run it, i wont to grep the the first 20 lines of it for an entry and basically do a crtl z out of it or to that effect, and output the results to a text file. I basically want to script... (5 Replies)
Discussion started by: k00061804
5 Replies

4. Shell Programming and Scripting

How to grep sql error in shell script and exit the script?

I need help in the following script. I want to grep the sql errors insert into the error table and exit the shell script if there is any error, otherwise keep running the scripts. Here is my script #!/bin/csh -f source .orapass set user = $USER set pass = $PASS cd /opt/data/scripts echo... (2 Replies)
Discussion started by: allinshell99
2 Replies

5. Shell Programming and Scripting

script use min resource ( grep grep)

Hi i wrote script use it as watchdog ( i mean it check another program (pooya) whenever that was killed (closed or crashed) it run another script (pooya_start.sh) to start it, this script work fine and do the job for me , i need help of an expert to tell me (exact command) how to change this... (8 Replies)
Discussion started by: pooyair
8 Replies

6. UNIX for Dummies Questions & Answers

grep IP script

Hello, I have a command and would like to make that as a script. How do I do that? my command is: grep -Eo +\.+\.+\.+. and i want to have that like grepscript.sh x.txt > IP.txt Can somebody help me? (3 Replies)
Discussion started by: eightball
3 Replies

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

8. Shell Programming and Scripting

Help with script - GREP

Hallo gentlemen, i've a problem removing lines from txt file. To make it simple, here is an example: TEXT1.TXT --- contents: 9.9.9.9 geek.net 1.1.1.1 geek.com 2.2.2.2 leet.net TEXT2.TXT --- contents: geek.com coolbar.org I simply do: cat text1.txt | grep -f text2.txt >... (7 Replies)
Discussion started by: mirkocosta
7 Replies

9. Shell Programming and Scripting

Grep Script

Hi, New to scripting and looking for some help. I am trying to write a script that will search a specified directory for any new or modified files within the last 7 days and display the results. This will be ran daily and emailed? Thanks (18 Replies)
Discussion started by: Con592
18 Replies

10. UNIX for Beginners Questions & Answers

Grep within script

Hi, I found script which compare ciphers with openssl and return back all result in "YES" (for matching) and "NO" (for no match) I want to result only "YES" part which can be achieved using grep but not sure how and where to place in below script" Script:... (1 Reply)
Discussion started by: khuharshree
1 Replies
LFC-DLI-CLIENT(1)						   User Commands						 LFC-DLI-CLIENT(1)

NAME
lfc-dli-client - lists the replicas for a given LFN, GUID via the DLI Interface SYNOPSIS
lfc-dli-client [ --endpoint endpoint ] [ -h || --help ] [ -v || --verbose ] logical file DESCRIPTION
lcg-dli-client lists the replicas for a given LFN or GUID using the Data Location Interface (DLI) Web service for a LFC Server. logical file a URI which specifies the Logical File Name ( lfn: ) or the Grid Unique IDentifier ( guid: ). endpoint specifies a web service endpoint to connect to. This consists of a http URL with a hostname and an optional port number. An example is http://lfc-dteam.cern.ch:8085/ NOTE
The environment variable LFC_HOST may be set instead of specifying an endpoint to use. Also, DLI_PORT may be used if the DLI is running on a non-standard port. If DLI_PORT is not specified, the client defaults to port 8085. EXAMPLE
lfc-dli-client -e http://lfc-dteam-test:8085/ lfn:/grid/dteam/dli-test sfn://lxb1533.cern.ch/storage//dteam/generated/2005-12-05/ filed88f9c0b-1fba-40a4-b20e-66866d757643 srm://lxb0724.cern.ch/pnfs/cern.ch/data/dteam/generated/ 2005-12-05/file9fd93cae-6400-4798-b4e9-2605bf31a7ff srm://lxb1921.cern.ch/dpm/cern.ch/home/dteam/generated/ 2005-12-05/file73c497d2-deed-46c8-b747-cda06c7708cb EXIT STATUS
This program returns 0 if the operation was successful or >0 if the operation failed. SEE ALSO
lcg_util(3), lcg-lr(3), lfc-dli(3) LCG
$Date: 2005/12/05 15:47:44 $ LFC-DLI-CLIENT(1)
All times are GMT -4. The time now is 09:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy