why the set rr='echo string|cut not working

I am new to the c shell script, can you let me know why the set rr= is not working.

C shell script

#! /bin/csh
 
Set tt= 12345_UMR_BH452_3_2.txt
set rr='echo $tt | cut �d�_�  -f1'
syntax error

Hi
Put backticks:

set rr=`echo $tt | cut -d�_� -f1`

Guru.

1 Like

here is the script

#! /bin/csh
set tt=12345_UMR_BH452_3_2.txt
set rr=`echo $tt | cut -d_  -f1`
set rr1=welcome
set ff=$rr $rr1
echo $ff

why echo $ff still return 12345 and not 12345welcome? thanks

Remove the space

set ff=$rr$rr1

Guru.

Or if you want the space use double quotes.

set ff="$rr $rr1"