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?
Answer
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
Comments
Post a Comment