-6

This shell script dosent give me any output:

GID="gmod01"
PID= screen -list | grep $GID | cut -f1 -d'.' | sed 's/\W//g'
echo $PID

Echo PID is empty, how can i fix this? I get 12055 out but it dosent copy in the value

Thank you

Sirch
  • 5,785
  • 4
  • 20
  • 36

1 Answers1

0

Use brackets.

GID="gmod01"
PID=$(screen -list | grep $GID | cut -f1 -d'.' | sed 's/\W//g')
echo $PID
Sirch
  • 5,785
  • 4
  • 20
  • 36
  • Dosent works... /restart: line 2: syntax error near unexpected token `|' ./restart: line 2: `PID=(screen -list | grep $GID | cut -f1 -d'.' | sed 's/\W//g')' – user2277716 Apr 29 '13 at 12:58
  • Will now, needs the bracket prefixed with a $ – Sirch Apr 29 '13 at 13:03