Cut - the delimiter must be a single character

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?

user2052801

Posted 2014-03-29T16:22:19.153

Reputation: 67

Answers

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

Posted 2014-03-29T16:22:19.153

Reputation: 530