I'd handle it as a stream instead of using arrays and dynamic variable names. xargs can be used to attach the stream of one program to the arguments of another to make things happen in even fewer shell steps. Much more straightforward.
I'd like to see what the output for pgrep -f "gcalctool" and cd /proc ; ls -ld somepid looks like for your system or I may get this somewhat wrong.
Hello all
while writing a small script , i got stuck with this simple thing.Hope you guyz can help.
Iam trying to read password
echo"enter password"
read $pwd
now i have to check this
echo"enter password to proceed"
read $pwd
now i have to check both the values of the... (2 Replies)
Hello,
I am having a bit of hard time to get my head around this one. I really hope someone is out there to help me out!
Background of my code:
I am doing some automation where I am verifying multiple files in multiple sub folders and if they are all identical, I would echo a line with my test... (0 Replies)
Hi,
I am trying to write a script to show the status of a Network card.
Variables:
chosennic is a read variable
statuss=`/sbin/ifconfig $chosennic | grep MTU | awk '{print $1}'`
ipadd=`/sbin/ifconfig $chosennic | grep Bcast | awk '{print $2}' | awk -F : '{print $2}'`... (2 Replies)
Hi!
I've come up with a ksh-script that produces one or more lists of hosts.
At the and of the script, I would like to print only those hosts that exists in all the lists.
Ex.
HOSTS="host1 host2 host3 host11"
HOSTS="host1 host2 host4"
HOSTS="host2 host11"
HOSTS="host2 host5 host6 host7... (1 Reply)
Hi,
I am a noob at shell scripting.
basically I am trying to compare row counts from 8 tables in different databases. I have managed to get the row counts using awk from the spool files for both databases.
now I have 16 variables with me
for database 1 :
$A
$B
$C
$D
$E
$F
$G... (3 Replies)
Hi all,
I have two files as below. I need to compare field 2 of file 1 against field 1 of file 2 and field 5 of file 1 against filed 2 of file 2. If both matches , then create a result file 1 with first file data and if not matches , then create file with first fie data. Please help me in... (12 Replies)
I want to develop one unix script that will first match the multiple files on one server say A with multiple files on another server say B and copy those to server A. After that need to compare the contents of these 2 set of multiple files on different location on same server and generate the... (4 Replies)
Hi ,
Can any please help the below requirement on all multiple servers and multiple dbs.
update configuration set value='yes' ;1)
the above statement apply on 31 Databases at a time on different Ip address
eg : 10.104.1.12 (unix ip address )
the above ip box contains 4 db's eg : db... (2 Replies)
Discussion started by: venkat918
2 Replies
LEARN ABOUT MINIX
pgrep
PGREP(1) User Commands PGREP(1)NAME
pgrep, pkill - look up or signal processes based on name and other attributes
SYNOPSIS
pgrep [options] pattern
pkill [options] pattern
DESCRIPTION
pgrep looks through the currently running processes and lists the process IDs which match the selection criteria to stdout. All the crite-
ria have to match. For example,
$ pgrep -u root sshd
will only list the processes called sshd AND owned by root. On the other hand,
$ pgrep -u root,daemon
will list the processes owned by root OR daemon.
pkill will send the specified signal (by default SIGTERM) to each process instead of listing them on stdout.
OPTIONS -signal
--signal signal
Defines the signal to send to each matched process. Either the numeric or the symbolic signal name can be used. (pkill only.)
-c, --count
Suppress normal output; instead print a count of matching processes. When count does not match anything, e.g. returns zero, the
command will return non-zero value.
-d, --delimiter delimiter
Sets the string used to delimit each process ID in the output (by default a newline). (pgrep only.)
-f, --full
The pattern is normally only matched against the process name. When -f is set, the full command line is used.
-g, --pgroup pgrp,...
Only match processes in the process group IDs listed. Process group 0 is translated into pgrep's or pkill's own process group.
-G, --group gid,...
Only match processes whose real group ID is listed. Either the numerical or symbolical value may be used.
-i, --ignore-case
Match processes case-insensitively.
-l, --list-name
List the process name as well as the process ID. (pgrep only.)
-a, --list-full
List the full command line as well as the process ID. (pgrep only.)
-n, --newest
Select only the newest (most recently started) of the matching processes.
-o, --oldest
Select only the oldest (least recently started) of the matching processes.
-P, --parent ppid,...
Only match processes whose parent process ID is listed.
-s, --session sid,...
Only match processes whose process session ID is listed. Session ID 0 is translated into pgrep's or pkill's own session ID.
-t, --terminal term,...
Only match processes whose controlling terminal is listed. The terminal name should be specified without the "/dev/" prefix.
-u, --euid euid,...
Only match processes whose effective user ID is listed. Either the numerical or symbolical value may be used.
-U, --uid uid,...
Only match processes whose real user ID is listed. Either the numerical or symbolical value may be used.
-v, --inverse
Negates the matching. This option is usually used in pgrep's context. In pkill's context the short option is disabled to avoid
accidental usage of the option.
-w, --lightweight
Shows all thread ids instead of pids in pgrep's context. In pkill's context this option is disabled.
-x, --exact
Only match processes whose names (or command line if -f is specified) exactly match the pattern.
-F, --pidfile file
Read PID's from file. This option is perhaps more useful for pkill than pgrep.
-L, --logpidfile
Fail if pidfile (see -F) not locked.
--ns pid
Match processes that belong to the same namespaces. Required to run as root to match processes from other users. See --nslist for
how to limit which namespaces to match.
--nslist name,...
Match only the provided namespaces. Available namespaces: ipc, mnt, net, pid, user,uts.
-V, --version
Display version information and exit.
-h, --help
Display help and exit.
OPERANDS
pattern
Specifies an Extended Regular Expression for matching against the process names or command lines.
EXAMPLES
Example 1: Find the process ID of the named daemon:
$ pgrep -u root named
Example 2: Make syslog reread its configuration file:
$ pkill -HUP syslogd
Example 3: Give detailed information on all xterm processes:
$ ps -fp $(pgrep -d, -x xterm)
Example 4: Make all netscape processes run nicer:
$ renice +4 $(pgrep netscape)
EXIT STATUS
0 One or more processes matched the criteria.
1 No processes matched.
2 Syntax error in the command line.
3 Fatal error: out of memory etc.
NOTES
The process name used for matching is limited to the 15 characters present in the output of /proc/pid/stat. Use the -f option to match
against the complete command line, /proc/pid/cmdline.
The running pgrep or pkill process will never report itself as a match.
BUGS
The options -n and -o and -v can not be combined. Let me know if you need to do this.
Defunct processes are reported.
SEE ALSO ps(1), regex(7), signal(7), killall(1), skill(1), kill(1), kill(2)AUTHOR
Kjetil Torgrim Homme <kjetilho@ifi.uio.no>
REPORTING BUGS
Please send bug reports to <procps@freelists.org>
procps-ng March 2015 PGREP(1)