Search Results

Search: Posts Made By: simpltyansh
3,530
Posted By RudiC
How about ps -e -o comm | grep -Eo...
How about
ps -e -o comm | grep -Eo "process(1|2|3)" | sort | uniq -c
3,530
Posted By apmcd47
If there are no instances of your required...
If there are no instances of your required processes they won't be listed in ps and therefore won't be counted by uniq.
Perhaps something like this will help you:
for p in process1 process2...
3,530
Posted By rbatte1
With the -E flag that you are already using, the...
With the -E flag that you are already using, the search is for a regular expression. You can include an expression so that grep will not find itself like this:-ps -ef | grep -E "Hell[o]"The [o]...
3,530
Posted By apmcd47
How about ps -e -o comm | grep -Eo...
How about

ps -e -o comm | grep -Eo 'process1|process2|process3| '|sort | uniq -c

When using ps always use the -o option to specify exactly which fields you need rather than use a full listing...
3,530
Posted By radioactive9
Hi Did you try | grep -v grep | ? ps...
Hi

Did you try | grep -v grep | ?

ps -ef|grep -Eo 'process1|process2|process3| '|grep -v grep |sort | uniq -c | awk '{print $2": "$1}'
3,530
Posted By apmcd47
Does your system have pgrep? If so, does it...
Does your system have pgrep? If so, does it support the -c, --count option?
Try this:

#!/bin/bash
for process in "$@"
do
printf "%s: %d\n" $process $(pgrep -c $process)
done


Andrew
1,300
Posted By jim mcnamara
consider a shorter bit of arithmetic: # the...
consider a shorter bit of arithmetic:

# the the age of the file using epoch seconds
fileage=$(( $(date +%s) - $(date -r min.h.bak +%s) ))
# age expressed as hours:
echo "hours = $(( $fileage /...
840
Posted By wisecracker
Or alternatively:- Last login: Tue Apr 1...
Or alternatively:-
Last login: Tue Apr 1 11:37:32 on ttys000
AMIGA:barrywalker~> a="OK"
AMIGA:barrywalker~> echo "Three files are : "$a"test.txt "$a"code.txt "$a"fun.txt"
Three files are :...
840
Posted By anbu23
It is not fetching value since atest.txt is...
It is not fetching value since atest.txt is considered as variable name. Use brace as below to indicate only a is variable name
a=ok
echo "Three files are : ${a}test.txt ${a}code.txt ${a}fun.txt"
Showing results 1 to 9 of 9

 
All times are GMT -4. The time now is 08:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy