Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to set the number of a particular process that are running to a variable. The first line of the csh script below is the problem as it sets the variable "number" as ps aux | grep -c fiji instead of the output of ps aux | grep -c fiji which should be 1.

#!/bin/csh

set number = 'ps aux | grep -c fiji'

if ( $number <= 1 ) then
(I run a command here)
else
echo $number
endif
share|improve this question

You should use backtics (`), not single quotes ('). This script

#!/bin/csh

set number = `ps aux | grep -c fiji`

echo $number

prints 1

share|improve this answer

general remark: your command will always return 1 or more, including the process you run for the grep. So you need to take care of this after evaluation, or use something like pgrep.

And then - csh. Have a look at http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ . And http://www.grymoire.com/Unix/CshTop10.txt .

still want to use csh ;-) ?

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .