05-07-2009
Comma delimited instead of space delimited
Hi,
What if the numbers are comma separated and the no.of occurences of the pattern is not known.
E.g. 1,2,3,4,...n
TIA
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I need to seach all strings that matches "if ; then" in all files
If i put
grep "if ; then" *.* it is not giving any result (1 Reply)
Discussion started by: pmsuper
1 Replies
2. Shell Programming and Scripting
Okay, well this is more or less my first attempt at writing a shell script.
Anyways, here's my code:
cd ${PATH}
if
then
rm ${FILE}
./anotherScript
else
exit 1
fi
exit 1
Anyways, it's a pretty simple script that is supposed to search for the... (4 Replies)
Discussion started by: cbo0485
4 Replies
3. Shell Programming and Scripting
Hi,
I want to use grep inside a test statement, but I am getting an error message.
Two variables
testvarNum=5
testvarNonNum=x
echo $testvarNum | grep *
The result of this is as follows:
5
However, when I try the following (i.e. to test if the variable is numeric or non-numeric):... (3 Replies)
Discussion started by: dkieran
3 Replies
4. Shell Programming and Scripting
Hello ...again.
I am stuck on this part, I have a loop with processes an operations file.
and calls different functions depending on what is in loop, which processes a database file...
#so far my add function works as intended
add()
{
...blah blah;
}
# delete is kinda working... (13 Replies)
Discussion started by: gcampton
13 Replies
5. Shell Programming and Scripting
Hi Team,
-rwxr-xr-x 1 kmani00 system 9 Nov 08 03:29 tempfile.txt
-rwxrwxrwx 1 kmani00 devgrp 0 Nov 08 03:32 testfile.txt
by exec the following command, i did not get any output.
> test -s tempfile.txt
> a=`test -s tempfile.txt`
> echo $a
>
by exec the... (4 Replies)
Discussion started by: kmanivan82
4 Replies
6. Shell Programming and Scripting
Hello all,
working on Solaris 10 in ksh.
Basicly, in my function, i'm trying to test that all my unix cmd's are true (exit status 0) else you flag the rcControlRule to 1 without going into spagetti mode code testing every $? in a if statement.
The mdb is probably a little tricky cause it... (3 Replies)
Discussion started by: maverick72
3 Replies
7. Shell Programming and Scripting
cat abc.txt
Filename: SHA_AED_Monthly_SNR_20150331.txt.gz
Data Format: ASCII with carriage returns and linefeeds
Compression: GZIP
GZIP Bytes: 36893068
Unzipped Bytes : 613794510
Records: 851310
Record Length: 738
Blocksize: 32472
Filename: SHA_AED_SNR_ChangeLog_20150331.txt.gz
Data... (16 Replies)
Discussion started by: dotran
16 Replies
8. Shell Programming and Scripting
I have a list of files like below, Do we have grep command to find files?
If i grep 03874 it should display the file 3874, Grep command should ignore 0 at the beginning. There could be more many leading 0's in filename.
$ ls -ltr
total 5
-rw-r--r-- 1 mqm mqm 15 Feb 19 17:07 4769... (3 Replies)
Discussion started by: prince1987
3 Replies
9. UNIX for Beginners Questions & Answers
I want to xheck if a file exists that uses wildcards as only the partial filename is known using the test Command, and when it exists then output just the number of lines in the file... do not include the filename. Then this output, is it captured by the CommandOutput or the ReturnValue as I want... (2 Replies)
Discussion started by: dsinco
2 Replies
10. Shell Programming and Scripting
As an exercise, I'm trying to re-write this code without the compound square brackets, using grep and test. Need to know what to do about the "equal-tilde".
#!/bin/bash
# test-integer2: evaluate the value of an integer.
INT=-5
if +$ ]]; then
if ; then
echo "INT is zero."
else
if ; then... (17 Replies)
Discussion started by: Xubuntu56
17 Replies
PKILL(1) BSD General Commands Manual PKILL(1)
NAME
pkill -- find or signal processes by name
SYNOPSIS
pgrep [-filnvx] [-d delim] [-G gid] [-g pgrp] [-P ppid] [-s sid] [-t tty] [-U uid] [-u euid] pattern ...
pkill [-signal] [-filnvx] [-G gid] [-g pgrp] [-P ppid] [-s sid] [-t tty] [-U uid] [-u euid] pattern ...
prenice [-l] priority pattern ...
DESCRIPTION
The pgrep command searches the process table on the running system and prints the process IDs of all processes that match the criteria given
on the command line.
The pkill command searches the process table on the running system and signals all processes that match the criteria given on the command
line.
The prenice command searches the process table on the running system and sets the priority of all processes that match the criteria given on
the command line.
The following options are available for pkill and pgrep:
-d delim Specify a delimiter to be printed between each process ID. The default is a newline. This option can only be used with the pgrep
command.
-f Match against full argument lists. The default is to match against process names.
-G gid Restrict matches to processes with a real group ID in the comma-separated list gid.
-g pgrp Restrict matches to processes with a process group ID in the comma-separated list pgrp. The value zero is taken to mean the
process group ID of the running pgrep or pkill command.
-i Ignore case distinctions in both the process table and the supplied pattern.
-l Long output. Print the process name in addition to the process ID for each matching process. If used in conjunction with -f,
print the process ID and the full argument list for each matching process.
-n Match only the most recently created process, if any.
-P ppid Restrict matches to processes with a parent process ID in the comma-separated list ppid.
-s sid Restrict matches to processes with a session ID in the comma-separated list sid. The value zero is taken to mean the session ID of
the running pgrep or pkill command.
-t tty Restrict matches to processes associated with a terminal in the comma-separated list tty. Terminal names may be specified as a
fully qualified path, in the form 'ttyXX', or 'pts/N', (where XX is any pair of letters, and N is a number), or the shortened forms
'XX' or 'N'. A single dash ('-') matches processes not associated with a terminal.
-U uid Restrict matches to processes with a real user ID in the comma-separated list uid.
-u euid Restrict matches to processes with an effective user ID in the comma-separated list euid.
-v Reverse the sense of the matching; display processes that do not match the given criteria.
-x Require an exact match of the process name, or argument list if -f is given. The default is to match any substring.
-signal A non-negative decimal number or symbolic signal name specifying the signal to be sent instead of the default TERM. This option is
valid only when given as the first argument to pkill.
The -l flag is also availale for prenice.
Note that a running pgrep or pkill process will never consider itself or system processes (kernel threads) as a potential match.
EXIT STATUS
pgrep, pkill, and prenice return one of the following values upon exit:
0 One or more processes were matched.
1 No processes were matched.
2 Invalid options were specified on the command line.
3 An internal error occurred.
SEE ALSO
grep(1), kill(1), ps(1), kill(2), sigaction(2), re_format(7), signal(7), renice(8)
HISTORY
pkill and pgrep first appeared in NetBSD 1.6. They are modelled after utilities of the same name that appeared in Sun Solaris 7.
prenice was introduced in NetBSD 6.0.
BSD
December 7, 2010 BSD