Confusion with echo command under csh shell


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Confusion with echo command under csh shell
# 1  
Old 07-25-2013
Tools 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:
Code:
expect ">"

so what I did is:
Code:
echo "expect "">"""  >> $loginFile

but it just gave out:
Code:
expect >

The thing is I still need the double quote the start and the end of the echo since there are lines which I need to use variable, such as:
Code:
echo "send ""cd $destDir""" >>$loginFile

ANd because of the reason I cannot use the single quote as well

Just to sum up, I need something that looks like:
Code:
echo "[content]" >> $loginFile

and can generate out the result above.
Thank you very much for your help Smilie really appreciate it
# 2  
Old 07-25-2013
Try
Code:
$ echo 'expect ">"'

expect ">"

$ echo "expect \">\""

expect ">"

# 3  
Old 07-25-2013
if you want to print the double quotes also in the file then just put a \ in front of the quotes you want to print.
double quotes are used to specify string and considered as a special character. if u are printing like this
Code:
echo "expect "">"""  >> $loginFile

then it takes 3 strings enclosed in 3 pair of double quotes
Code:
1) "expect "
2) ">"
3) ""

hence you are getting the result as expect >
if you want to remove the special meaning of any metacharacter , put a \ before that chatracter.
Code:
echo "expect \">\""  >> $loginFile

 
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

Pass C shell array to another C shell script(csh) and shell(sh)

Dear Friends, Please help me on this my script name is send.csh In this i have written the statement like this set args = ( city state country price ) I want to pass this array to another c shell called receiver.csh. and i want to use it in this c shell or how to pass to... (2 Replies)
Discussion started by: SA_Palani
2 Replies

3. Shell Programming and Scripting

How to echo output of a UNIX command (like ls -l ) using shell script.?

How do i echo the output of a unix command using shell script??? Like: echo /etc/ ls -l (2 Replies)
Discussion started by: sunny2802
2 Replies

4. UNIX for Dummies Questions & Answers

[Query] Confusion of the Swap when using 'free -m' command

Hi All, I have just installed my first Linux server ( Ubuntu 11.10 ). I am sure I didn't allocate /swap , and double check by 'df -h', yes really no /swap but when I use 'free -m' , returned a "Swap" line as below. total used free shared buffers cached Mem: ... (3 Replies)
Discussion started by: joaming
3 Replies

5. Shell Programming and Scripting

Confusion about FOR LOOP syntax between Bourne and BASH shell. Please see.

for (( i=1; i<=3; i++ )); do for (( j=1; j<=3; j++ )); do for (( k=1; k<=3; k++ )); do echo $i$j$k done done done Will the above code work on a BOURNE shell? As far as my understanding is, if I am writing the above code in a file..say lol.sh and then running it through the terminal using... (7 Replies)
Discussion started by: navienavnav
7 Replies

6. Shell Programming and Scripting

C Shell in linux.. only recognizes echo command

Hi guys, So my code is below. This is a simplified version of the shell... It does not continue for ever... I guess its actually rather a program to accept a command.. has the fork and the execve etc. Anyways when i compile it and run it in the terminal for some reason only '/bin/echo "enter... (1 Reply)
Discussion started by: 1bh
1 Replies

7. Shell Programming and Scripting

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. set msg2 = " -Inmod= -Nxz= -Varp=" echo $msg2 (3 Replies)
Discussion started by: kristinu
3 Replies

8. Solaris

Confused with echo $SHELL Command....

Hi.. Everyone... Kindly consider following : login as: root Using keyboard-interactive authentication. Password: Last login: Mon Nov 3 19:30:50 2008 from xxxxxxxxxxx Sun Microsystems Inc. SunOS 5.10 Generic January 2005 You have new mail. Sourcing //.profile-EIS..... # # ... (3 Replies)
Discussion started by: Reboot
3 Replies

9. UNIX for Advanced & Expert Users

Mail command confusion

When i run this command on my linux machine: mail -s "CVS ALERT-CRITCAL" sandy@xyz.com The system hangs up producing a dead letter. What should i do to resolve this. I am using : mailx -s "CVS ALERT-CRITCAL" sandy@xyz.com This cammnd works fine on another Linux machine but says"... (14 Replies)
Discussion started by: bsandeep_80
14 Replies

10. UNIX for Dummies Questions & Answers

wc command confusion

Can somebody explain it to me that why wc gives more chars suppose Ab.txt have two lines qwer qasd then wc -c ab.txt will give 10.why not 8.okay may be it is taking count one for each line just in case but why echo "qwer"|wc -C gives 5. Ok with \c it is returning 4. :) (6 Replies)
Discussion started by: Dhruva
6 Replies
Login or Register to Ask a Question