6

I have a number in a text file like :

int_width: 5230

I want to set this number (5230) to a variable in csh. What is the correct form? (grep is working before setting)

set WIDTH = "$(grep int_width  *.txt | sed 's/[^0-9]*//g')"
muru
  • 207,228
Krsztr
  • 477

1 Answers1

9
  1. In order to set variable in csh you need to use set (more info)
  2. As mentioned by @muru comment - The original Bourne shell, csh or tcsh all do not support $() and require ` ` for command substitution.

Combine the above two and you'll get:

% set WIDTH=`grep int_width *.txt | sed "s,[^0-9]*,," `
% echo $WIDTH
5230
muru
  • 207,228
Yaron
  • 13,453