03-12-2007
Using Grep within a UNIX Script
Hi,
I'm trying to save the wc from a grep command in my unix script and then later in my script I try to reference the variable but I have no luck. Any help is greatly appreciated!
--------------------
set xTest = 'grep -i lisa daily.log'
if [$xTest == 0] ;
then
echo "TEST" >> daily.log
fi
--------------------------
Thanks,
Lisa
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
BACKGROUND:
I am using Solaris 10. Some of my boxes have gnu grep and I can use -A and -B flags on those. However, the solaris flavor of grep won't use the flags -A or -B. And some of my boxes won't be getting gnu grep.
Should I try using perl, awk, or sed?
Actual PROBLEM: I am... (7 Replies)
Discussion started by: el_guero
7 Replies
2. Shell Programming and Scripting
Hi,
I am new to UNIX Shell scripting, and will require some help.
I am trying to search a directory with a number of files for a specific word, then if that word is found in any of the files, then the filename is appended to a log file or result file by ">" command.
I have been trying to... (2 Replies)
Discussion started by: Sypherg
2 Replies
3. Shell Programming and Scripting
Hola, solicito ayuda para procesar un archivo de texto como el siguiente y luego obtener las variables.
archivo.txt:
Sending 5, 100-byte ICMP Echos to 10.249.98.94, timeout is 2 seconds:
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/33/44 ms
Variables a obtener:
... (5 Replies)
Discussion started by: mmunarriz
5 Replies
4. UNIX for Dummies Questions & Answers
Hello,
I looking to use grep to return a string with exactly n matches.
I'm building off this:
ls -aLl /bin | grep '^.\{9\}x' | tr -s ' '
-rwxr-xr-x 1 root root 632816 Nov 25 2008 vi
-rwxr-xr-x 1 root root 632816 Nov 25 2008 view
-rwxr-xr-x 1 root root 16008 May 25 2008... (7 Replies)
Discussion started by: MykC
7 Replies
5. UNIX for Dummies Questions & Answers
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
6. Shell Programming and Scripting
I am looking for advice on how to write a script that will rename and/or move files to a different directory based upon the results of a grep.
Let's say I have ten files in a directory. Some of them - not all - contain the text 'HELLO'. I would like to be able to grep the files for that text,... (3 Replies)
Discussion started by: rjhjr64
3 Replies
7. Shell Programming and Scripting
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
8. Shell Programming and Scripting
Hello,
I am a new Unix user and new to shell programming. I am working on a script to go through a log file and find the text error:
grep -i 'error' monplus.mplog
if I find the text error in the log file I would like to echo a message to the operator staing there is an error
I am currently... (2 Replies)
Discussion started by: dtracy01
2 Replies
9. Shell Programming and Scripting
Hi guys,
I'm not a frequent visitor of this site so please forgive if this has been asked before.
I'm trying to monitor the swap memory usage on my Solaris 10 Unix server.
The command I'm wanting to run is: swap -s
The output is:
total: 33332016k bytes allocated + 40373832k... (2 Replies)
Discussion started by: d-train
2 Replies
10. Programming
Hello,
Fairly simple really I have an xml file and I want to check to see if it contains a pattern. The pattern is "../"
On the command line I can type: grep "\.\./" myFile.xml
and I get desired result.
To do the same thing in a perl script I thought it was as simple as putting the ``... (4 Replies)
Discussion started by: Jaymoney
4 Replies