Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Reset $1 variable

$
0
0
Hi all,

I'm using a scipt with one input and one output.
I'm referring to the input by $1
after executing a command line, I'm getting the output via $1.
Normally, the $1 shouldn't get the same values between the first call and the second.
Is there a solution to force my second call for $1 to get the value of $PS -efo pcpu,vsz,arg

Here is my script:
Code:

SWAPINFO="/usr/sbin/swapinfo"
PS="/usr/bin/ps"
AWK="/usr/bin/awk"
GREP="/usr/bin/grep"
SORT="/usr/bin/sort"
TAIL="/usr/bin/tail"


MYPAT="$1"
Availability=0
export UNIX95=1
VAR=$($SWAPINFO -ta | $GREP memory | $AWK ' { print $2 } ')
MYCPU=` $PS -efo pcpu,vsz,args | $GREP -v COMMAND | $GREP -v awk | $GREP "$MYPAT" | $SORT -k 1 | $TAIL -1 | $AWK -v var=$VAR -v pattern="$MYPAT" ' { print $1 } '`
echo $MYCPU


Viewing all articles
Browse latest Browse all 16232

Trending Articles