CSH: echo a string having []


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting CSH: echo a string having []
# 1  
Old 06-19-2010
CSH: echo a string having []

I am trying to use echo in CSH and getting an error.

I want to use [] to tell the user which parameters are optional.

Code:
    set msg2 = "[-Base=] [-Data=] -Inmod= [-Fout] -Nxz= [-Npop=] -Varp="
    echo $msg2

# 2  
Old 06-19-2010
Seems to work if you quote the echo:

Code:
    set msg2 = "[-Base=] [-Data=] -Inmod= [-Fout] -Nxz= [-Npop=] -Varp="
    echo "$msg2"

It might be a globbing issue, but as it's C-Shell, I'd just quote the echo!

It's standard procedure to point you to these links:

Csh Programming Considered Harmful
Top Ten Reasons not to use the C shell
# 3  
Old 06-19-2010
Thanks. Does the [] have special meaning? As when I remove them echo shows no problem.
# 4  
Old 06-19-2010
From the csh man page:
Quote:
The search string may be a glob-
pattern (see Filename substitution) containing `*', `?', `[]' or `{}'.
and

Quote:
Glob-patterns which do not use `?', `*', or `[]'
suggests that they may. These quotes may, or may not be relevant to your code, but to be honest, you should read the manual page and other documentation for CSH.

Last edited by Scott; 06-19-2010 at 03:41 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

About echo command in csh

hi linux expert I want to print the following lines ( or similar) with the echo command in csh script. how to do it when the number of lines is high and the use of the \ symbol for each line is difficult? Thanks in advance samad 000 'iexpt ' = experiment number x10 (000=from... (4 Replies)
Discussion started by: abdossamad2003
4 Replies

2. Shell Programming and Scripting

String operation in csh AIX 4.3.2.0

Hi to everybody i stuck on a simple thing i had a string and i want cut it , i try already few thing with the cut command but does not the way it should. The script is in csh and running on AIX 4.3.2.0 here are few samples how the string can look like FT71;1;1;1;;;1;31.01.2017... (9 Replies)
Discussion started by: Nadielosabra
9 Replies

3. Shell Programming and Scripting

String operation in csh shell

Hi, to everybody i have a string which Looks like this FT47;3;1;1;;;1;09.02.2017 21:21:19;2;2 and i would like to change to value on one Position only e.g. the values on Position 6 should change to 1 nevertheyless which values was there before AIX 4.3.2.0 and csh i try... (10 Replies)
Discussion started by: Nadielosabra
10 Replies

4. Shell Programming and Scripting

Find a string in all files and echo a message

Hi. I m trying to figure out how to do this. I have a directory full of files (100 files) and I want to be able to search for a string called "end" at the end of the files (last line or last 5 lines) and echo each file to say "incomplete" if not found. This is what I have so far. ---... (4 Replies)
Discussion started by: jasonhawaii
4 Replies

5. UNIX for Dummies Questions & Answers

String size limit for 'echo'...

Hi guys, man bash doesn't help much here nor does the WWW. (I have discovered there is technically no limit to a bash array.) I am thinking of adding a new full manual inside AudioScope.sh. A few questions here. The main question is, assuming I go ahead with this idea:- Is there a limit... (6 Replies)
Discussion started by: wisecracker
6 Replies

6. UNIX for Dummies Questions & Answers

Confusion with echo command under csh shell

HI, guys, I am having some problem with the echo command, so I want to echo some text to a file name loginFile, the result inside the loginFile should looks like: expect ">" so what I did is: echo "expect "">""" >> $loginFile but it just gave out: expect > The thing is I still need... (2 Replies)
Discussion started by: warmboy610
2 Replies

7. 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

8. Shell Programming and Scripting

String processing in CSH

Please delete it (0 Replies)
Discussion started by: animesharma
0 Replies

9. Shell Programming and Scripting

Csh Problem using spaces in string variables

I have done something like this set phases = "a b" set phases = "phases="$phases echo $phases I get phases=a instead of phases=a b (3 Replies)
Discussion started by: kristinu
3 Replies

10. Shell Programming and Scripting

Removing back quotes from string in CSH

Hello, I am using csh to read a text file and save its words into variable $word in a foreach loop. These words have small back quotes ` as integral parts of them, for example, one word would be `abc`, another would be `xyz1` etc... These quotes are always the first and last characters of the... (5 Replies)
Discussion started by: aplaydoc
5 Replies
Login or Register to Ask a Question