1

I am trying to cut the information from a variable of a variable. I am using csh. Ex:

setenv time \`date | cut -d ' ' -f 4\`
echo $time
setenv hour \`$time | cut -d \':\' -f 1\`
echo $hour

Output:

09:18:47
09:18:47: Command not found.
cut: the delimiter must be a single character
Try \`cut --help\' for more information.

Can some one please help me?

devnull
  • 3,305
  • 2
  • 16
  • 23
user2052801
  • 77
  • 4
  • 17

1 Answers1

1

First, on line three, you're trying to run a command stored in the $time variable. You need to echo it to pass it into cut. Second, cut takes a single delimiter, the quotes don't need to be escaped. Try this:

setenv time `date | cut -d ' ' -f 4`
echo $time
setenv hour `echo $time | cut -d ':' -f 1`
echo $hour
eToThePiIPower
  • 590
  • 5
  • 10