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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting why the set rr='echo string|cut not working
# 1  
Old 07-06-2010
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
Code:
#! /bin/csh
 
Set tt= 12345_UMR_BH452_3_2.txt
set rr='echo $tt | cut –d”_”  -f1'
syntax error


Last edited by pludi; 07-06-2010 at 02:10 PM.. Reason: code tags, please...
# 2  
Old 07-06-2010
Hi
Put backticks:

Code:
set rr=`echo $tt | cut -d”_” -f1`

Guru.
This User Gave Thanks to guruprasadpr For This Post:
# 3  
Old 07-06-2010
string concatnation

here is the script

Code:
#! /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
Moderator's Comments:
Mod Comment Code tags, please...

Last edited by pludi; 07-06-2010 at 02:56 PM..
# 4  
Old 07-07-2010
Remove the space

Code:
set ff=$rr$rr1

Guru.
# 5  
Old 07-07-2010
Or if you want the space use double quotes.

Code:
set ff="$rr $rr1"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Echo not working with $

$cat FILE.txt $PATH1/file1.txt $PATH2/file2.txt where$PATH 1 = /root/FILE_DR/file1.txt $PATH 2 = /root/FILE_DR/file2.txt for I in `cat FILE.txt` do v=`echo $I` echo $v if then rm $v (5 Replies)
Discussion started by: ekharvi
5 Replies

2. UNIX for Dummies Questions & Answers

Problem with echo and cut

Hi, My source file happens to be src.src with following contents: 1,liv 52,syrup,twice a day,children When I do a : for ii in `cat src.src` do echo $ii medicine_name=`echo $ii | cut -f -d2","` echo $medicine_name done I get output of echo $medicine_name as : an the output of... (2 Replies)
Discussion started by: dipanchandra
2 Replies

3. UNIX for Dummies Questions & Answers

set echo off and on

Hi I have written a bash script to capture the output of jmap. The command i execute is jmap -heap <pid> This gives details of memory usage of the process with <pid>. Now jmap not only gives this info but also prints couple more lines, which i am not interested in. Here are the lines that I... (3 Replies)
Discussion started by: avinthm
3 Replies

4. Shell Programming and Scripting

tcsh - understanding difference between "echo string" and "echo string > /dev/stdout"

I came across and unexpected behavior with redirections in tcsh. I know, csh is not best for redirections, but I'd like to understand what is happening here. I have following script (called out_to_streams.csh): #!/bin/tcsh -f echo Redirected to STDOUT > /dev/stdout echo Redirected to... (2 Replies)
Discussion started by: marcink
2 Replies

5. Shell Programming and Scripting

Advice using cut & echo combination commands

Hi, I am cutting data from a fixed length test file and then writing out a new record using the echo command, the problem I have is how to stop multiple spaces from being written to the output file as a single space. Example: cat filea | while read line do field1=`echo $line | cut -c1-2` ... (6 Replies)
Discussion started by: dc18
6 Replies

6. Linux

set echo off command issue

Hi all, I am executing a Oracle SQL statement in a shell script and spooling the output of the query into a File with spool command. I want to ensure that only output of the query appears in file excluding the SQL statement but even set echo off command is not working. Please help (7 Replies)
Discussion started by: sumi_mn
7 Replies

7. Shell Programming and Scripting

storing output from echo & cut into variable

Hi All, Hope someone can advise here as I have been struggling to find a syntax that works here. I have tried a stack of combination I have seed in the forums but I think because I have needed to use "" and `` in the statments another method is found. I am reading in lines with the following... (1 Reply)
Discussion started by: nkwilliams
1 Replies

8. Shell Programming and Scripting

echo just 1 line before execution/set +-x

Suppose that you want to mostly not echo commands inside your script during execution (e.g. to not bog the user down with details that they do not care about) but that there is the occaisional script line that you would like to echo before you execute it. Is there an elegant way to achieve this?... (3 Replies)
Discussion started by: fabulous2
3 Replies

9. UNIX for Dummies Questions & Answers

set variable to Home, then echo it to screen

Major Newbie here folks. I'm trying to set a variable to my Home directory and then echo it to the screen. Any and all help is greatly appreciated. Thanks Anna (3 Replies)
Discussion started by: amidget
3 Replies

10. Shell Programming and Scripting

How to set echo on

I'm looking at my bash man page and I'm expecting to find some option that I can use to make it echo every command that it executes. The description of --verbose was pretty terse! Is --verbose supposed to make it echo every command it executes? My bash script script (named ws2) contains a... (1 Reply)
Discussion started by: siegfried
1 Replies
Login or Register to Ask a Question