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

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.

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

Thanks for response

in this script (see attachment)
Do you have any idea to use echo command?

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:

#! /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:

:/"/;/"/-1s/$/\\/

Why is that too hard to do?

A here document is a good alternative because it takes the text as is

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.

1 Like