Sponsored Content
Top Forums UNIX for Dummies Questions & Answers capturing the output of grep as integer variable Post 10567 by babariba on Friday 16th of November 2001 09:42:40 AM
Old 11-16-2001
Thanks for your reply. I'm still a little uncertain about performing any kind of operation on this returned value. I actually only want to determine if there is a processID, and if there is, kill it. (That part I have, using a | xargs kill.) If there isn't a process then just carry on doing whatever comes next in the script.

So I'm trying this:

if ( $processID > 0 ) then ...


but I get an error,
16305: not found

(where 16305 is the value of the variable).
What is it that's not being found?

Should I just make it simpler and compare $processID to null or ""?

Thanks.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

redirect the grep output into the variable

i want to redirect the grep output into the variable but i am not able to get it i tried veri=`grep -i $1 "${logdir}"* | grep -i adding | grep -iv equation | tail -1 | cut -d ':' -f 1` vari=$(grep -i $1 "${logdir}"* | grep -i adding | grep -iv equation | tail -1 | cut -d ':' -f 1) BUT NOT... (1 Reply)
Discussion started by: mail2sant
1 Replies

2. Shell Programming and Scripting

Put the output of grep in a variable

Hi, in a shell script how can I put the result of a grep command in a variable : myvariable=grep mystring myfilename Thank you. (3 Replies)
Discussion started by: big123456
3 Replies

3. Shell Programming and Scripting

Problem with assigning output of grep + awk to a variable

Hi All, I am getting the output for the following command when i run it on the unix console. --------------------------- grep `whoami` /etc/passwd | awk '{print ($1);}' | cut -d ":" -f3 ---------------------------- But i made it into a script and tried to print the variable, its... (5 Replies)
Discussion started by: meheretoknow
5 Replies

4. Shell Programming and Scripting

Losing new lines when capturing output to variable

Explain this? $ ls | grep -e "crd\|cs" crd cs $ CLONES=`ls | grep -e "crd\|cs"`;echo $CLONES; crd cs $ CLONES=`ls | grep -e "crd\|cs"`;echo "$CLONES"; crd cs (1 Reply)
Discussion started by: blasto333
1 Replies

5. Shell Programming and Scripting

capturing output from top and format output

Hi all, I'd like to capture the output from the 'top' command to monitor my CPU and Mem utilisation.Currently my command isecho date `top -b -n1 | grep -e Cpu -e Mem` I get the output in 3 separate lines.Tue Feb 24 15:00:03 Cpu(s): 3.4% us, 8.5% sy .. .. Mem: 1011480k total, 226928k used, ....... (4 Replies)
Discussion started by: new2ss
4 Replies

6. Shell Programming and Scripting

Capturing output of procedure in variable in shell script

Hi guys I am calling one DB2 stored proc through unix. It is giving me below output. I want to capture the value 150 in one UNIX variable in shell script. Please let me know how I can achieve this. Thanks in advance Value of output parameters -------------------------- Parameter Name :... (5 Replies)
Discussion started by: vnimavat
5 Replies

7. Shell Programming and Scripting

AWK/GREP: grep only lines starting with integer

I have an input file 12.4 1.72849432773174e+01 -7.74784188610632e+01 12.5 9.59432114416327e-01 -7.87018212757537e+01 15.6 5.20139995965960e-01 -5.61612429666624e+01 29.3 3.76696387248366e+00 -7.42896194101892e+01 32.1 1.86899877018077e+01 -7.56508762501408e+01 35 6.98857157014640e+00... (2 Replies)
Discussion started by: chrisjorg
2 Replies

8. Shell Programming and Scripting

[SOLVED] Capturing output in a korn variable

Hi, I'm new to korn and having trouble capturing the text output from one program in an array that I can then feed into another program. Direct approaches didn't work, so I've tried to break it down thus: The program lonlat2pixline gives the values I need in the second column, so I print that... (4 Replies)
Discussion started by: daurin
4 Replies

9. Shell Programming and Scripting

Capturing Output?

Hello All, I'm writing a Bash Script and in it I execute a piped command within a Function I wrote and I can't seem to redirect the stderr from the 1st pipe to stdout..? I'm setting the output to an Array "COMMAND_OUTPUT" and splitting on newlines using this --> "( $(...) )". By putting... (6 Replies)
Discussion started by: mrm5102
6 Replies

10. Shell Programming and Scripting

Output of a Grep(Which already has a variable) into a Variabale

Hi All, I have a an array, in which i need to loop through all the variable and check each variable individually for a pattern. For ex #!/bin/ksh set -A FileNames $(</Temp/AllNames) echo "Total array elements :" ${#FileNames } for i in ${FileNames} do # if the "${i} | grep Last"... (3 Replies)
Discussion started by: baranisachin
3 Replies
KILLALL(1)						    BSD General Commands Manual 						KILLALL(1)

NAME
killall -- kill processes by name SYNOPSIS
killall [-d | -v] [-h | -?] [-help] [-l] [-m] [-s] [-u user] [-t tty] [-c procname] [-SIGNAL] [procname ...] DESCRIPTION
Killall kills processes selected by name, as opposed to the selection by pid as done by kill(1). By default, it will send a TERM signal to all processes with a real UID identical to the caller of killall that match the name procname. The super-user is allowed to kill any process. The options are as follows: -d | -v Be more verbose about what will be done. For a single -d option, a list of the processes that will be sent the signal will be printed, or a message indicating that no matching processes have been found. -h | -? -help Give a help on the command usage and exit. -l List the names of the available signals and exit, like in kill(1). -m Match the argument procname as a (case insensitive) regular expression against the names of processes found. CAUTION! This is dangerous, a single dot will match any process running under the real UID of the caller. -s Show only what would be done, but do not send any signal. -SIGNAL Send a different signal instead of the default TERM. The signal may be specified either as a name (with or without a lead- ing SIG), or numerically. -u user Limit potentially matching processes to those belonging to the specified user. -t tty Limit potentially matching processes to those running on the specified tty. -c procname When used with the -u or -t flags, limit potentially matching processes to those matching the specified progname. ALL PROCESSES
Sending a signal to all processes with uid XYZ is already supported by kill(1). So use kill(1) for this job (e.g. $ kill -TERM -1 or as root $ echo kill -TERM -1 | su -m <user>) DIAGNOSTICS
The killall command will respond with a short usage message and exit with a status of 2 in case of a command error. A status of 1 will be returned if either no matching process has been found or not all processes have been signalled successfully. Otherwise, a status of 0 will be returned. Diagnostic messages will only be printed if requested by -d options. SEE ALSO
kill(1), sysctl(3) HISTORY
The killall command appeared in FreeBSD 2.1. It has been modeled after the killall command as available on other platforms. AUTHORS
The killall program was originally written in Perl and was contributed by Wolfram Schneider, this manual page has been written by Jorg Wunsch. The current version of killall was rewritten in C by Peter Wemm using sysctl(3). BSD
June 25, 1995 BSD
All times are GMT -4. The time now is 07:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy