About echo command in csh


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers About echo command in csh
# 1  
Old 02-20-2019
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



Code:
000    'iexpt ' = experiment number x10 (000=from archive file)
  3    'yrflag' = days in year flag (0=360J16,1=366J16,2=366J01,3-actual)
  0     'ntracr' = number of tracers (to plot, optional with default 0)
 213    'idm   ' = longitudinal array size
 363    'jdm   ' = latitudinal  array size
 49    'kdm   ' = number of layers
 10.0    'thbase' = reference density (sigma units)
  1    'nperfr' = number of horizontal plots per frame
  1    'lalolb' = spacing of latitude/longitude labels
  1    'lalogr' = spacing of latitude/longitude grid over land (<0 land+sea)
  4    'loclab' = location of the contour label (0=input,1=upr,2=lowr,3=lowl,4=upl)
 11    'locbar' = location of the color bar     (1[0-4]=vert,2[0-4]=horiz,10=right, 20=bottom,15=cr,16=cl ,25=ct,26=cb)
  0     'gray  ' = no color (0=color,1=neg.gray,2=pos.gray), OPTIONAL default

# 2  
Old 02-20-2019
Quote:
Originally Posted by abdossamad2003
I want to print the following lines ( or similar) with the echo command in csh script.
Could you please be more or less precise? Depending on what "similar" means to you absolutely every script, printing or not, might do, regardless of what it does.

Save for that, you definitely should not use csh for scripting (or for anything else, for that matter) since perhaps the last 25 years and there is absolutely no reason to do so.

Quote:
Originally Posted by abdossamad2003
how to do it when the number of lines is high and the use of the \ symbol for each line is difficult?
Sorry, but i have no idea what you are talking about. Please explain what it is you want to do and what you want to achieve.

I hope this helps.

bakunin
# 3  
Old 02-20-2019
Thanks for response


in this script (see attachment)
Do you have any idea to use echo command?
# 4  
Old 02-20-2019
As has already been stated; you should not use csh for scripting (or anything else), but if you're going to ignore our advice, I don't see why (if you insist on using csh) that the following would not provide suitable output:
Code:
#! /bin/csh

echo "\
000    'iexpt ' = experiment number x10 (000=from archive file)\
  3    'yrflag' = days in year flag (0=360J16,1=366J16,2=366J01,3-actual)\
  0     'ntracr' = number of tracers (to plot, optional with default 0)\
 213    'idm   ' = longitudinal array size\
 363    'jdm   ' = latitudinal  array size\
 49    'kdm   ' = number of layers\
 10.0    'thbase' = reference density (sigma units)\
  1    'nperfr' = number of horizontal plots per frame\
  1    'lalolb' = spacing of latitude/longitude labels\
  1    'lalogr' = spacing of latitude/longitude grid over land (<0 land+sea)\
  4    'loclab' = location of the contour label (0=input,1=upr,2=lowr,3=lowl,4=upl)\
 11    'locbar' = location of the color bar     (1[0-4]=vert,2[0-4]=horiz,10=right, 20=bottom,15=cr,16=cl ,25=ct,26=cb)\
  0     'gray  ' = no color (0=color,1=neg.gray,2=pos.gray), OPTIONAL default\
"

and, adding those backslash characters to your sample input file took one command in vi. That command was:
Code:
:/"/;/"/-1s/$/\\/

Why is that too hard to do?

Last edited by RudiC; 02-20-2019 at 06:42 AM.. Reason: typo
# 5  
Old 02-20-2019
A here document is a good alternative because it takes the text as is
Code:
cat << _EOT
000    'iexpt ' = experiment number x10 (000=from archive file)
  3    'yrflag' = days in year flag (0=360J16,1=366J16,2=366J01,3-actual)
  0     'ntracr' = number of tracers (to plot, optional with default 0)
 213    'idm   ' = longitudinal array size
 363    'jdm   ' = latitudinal  array size
 49    'kdm   ' = number of layers
 10.0    'thbase' = reference density (sigma units)
  1    'nperfr' = number of horizontal plots per frame
  1    'lalolb' = spacing of latitude/longitude labels
  1    'lalogr' = spacing of latitude/longitude grid over land (<0 land+sea)
  4    'loclab' = location of the contour label (0=input,1=upr,2=lowr,3=lowl,4=upl)
 11    'locbar' = location of the color bar     (1[0-4]=vert,2[0-4]=horiz,10=right, 20=bottom,15=cr,16=cl ,25=ct,26=cb)
  0     'gray  ' = no color (0=color,1=neg.gray,2=pos.gray), OPTIONAL default
_EOT

It copies the next lines until the _EOT marker is found at the beginning of the line. (Any unique word can be used as an end marker.)
This will substitute a $variable by its value (like in echo "$variable").
If the opening marker is in quotes cat << "_EOT" it will NOT replace a $variable by its value.
This User Gave Thanks to MadeInGermany For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

If command in csh

hi everyone what is difference between "if ( -e Arch )" and "if ( -e ./Arch )" in csh shell? Many Thanks samad (1 Reply)
Discussion started by: abdossamad2003
1 Replies

2. Shell Programming and Scripting

Need to echo command successful if command is executed successfully

Hello, I have written a command n shell script : srvctl relocate service -d t1 -s s1 -i i1 -t t1 -f If the above command executes successfully without error I need to echo "Service relocated successfully and If it errors out I need to trap the errors in a file and also need to make... (1 Reply)
Discussion started by: Vishal_dba
1 Replies

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

4. Shell Programming and Scripting

Help on command line argument in csh

HI , I am new to csh. I need to pass some command line arguments like ./abc.sh -os Linux -path abc -tl aa -PILX 1 I have defined the loop as shown below. But its taking "-os" switches as arguments. Its treating them as arguments. How to resolve it? while ( $#argv != 0 ) switch ($argv) ... (7 Replies)
Discussion started by: vineet.dhingra
7 Replies

5. Shell Programming and Scripting

AIX : Need help with <join> command in csh

Hi All, I need your hand to resolve an issue I am facing with a join command in one of the script. Please see the 3 files attached where file1 and file2 are the two files I am passing to the join command written in the command file. Prior to calling the join I am also sorting both the files on... (6 Replies)
Discussion started by: sraj142
6 Replies

6. UNIX for Dummies Questions & Answers

csh command not found

I get a "command not found" error when I run the csh command. I also get this error when I start a new session since my default shell is c shell. Any pointers as to what is going on? I am trying to set some paths using the .cshrc file and need to use the csh command for this. Thanks. (1 Reply)
Discussion started by: kannyg
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. Shell Programming and Scripting

Is there any thing like this perl command is csh?

I mean this : perl -pi -e 's/OS/blah/g' *.c* The Great thing in such thing i dont need to rename orig then rename back when i do it with sed for instance inside csh shell , is there any way to avoid this with sed/awk/what ever? Thanks (4 Replies)
Discussion started by: umen
4 Replies

9. Shell Programming and Scripting

csh -f and the at command

Hi everyone. I am new to the forums and new to Unix, so please pardon my beginner "status". In my company, we have a few C shell scripts, which we call BAT files (!). They all start with the usual "#/bin/csh" line to get it to run the .cshrc script which preloads the session with a lot of... (1 Reply)
Discussion started by: SpanishPassion
1 Replies

10. UNIX for Dummies Questions & Answers

csh and the set command

Hi, I am trying to write a csh script that will run another csh script, but redirect the output from the second script to an email. my code looks like this. #!/bin/csh ## This script is designed to run the SSM.sh ## then email the output to a specified email address ## it will also display... (2 Replies)
Discussion started by: jagannatha
2 Replies
Login or Register to Ask a Question