Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spaces interpreted as newline 1

Status
Not open for further replies.

630111

MIS
Oct 30, 2001
127
US
Here's my script

#! /bin/sh
SPAN1="-d 10/18/2004 17:00 -e 10/22/2004 06:00"
SPAN2="-d 10/22/2004 17:00 -e 10/25/2004 06:00"
SPAN3="-d 10/25/2004 17:00 -e 10/29/2004 06:00"

for I in $SPAN1 $SPAN2 $SPAN3
do
echo $I
done

My output looks like this

-d
10/18/2004
17:00
-e
10/22/2004
06:00
-d
10/22/2004
17:00
-e
10/25/2004
06:00

How do I get it to output like this?

-d 10/18/2004 17:00 -e 10/22/2004 06:00
-d 10/22/2004 17:00 -e 10/25/2004 06:00
-d 10/25/2004 17:00 -e 10/29/2004 06:00

Thanks, in advance!
630111

 
What about this ?
for I in "$SPAN1" "$SPAN2" "$SPAN3"
do
echo "$I"
done


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
for I in "$SPAN1" "$SPAN2" "$SPAN3"

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
THANKS PHV !!

Why are the quotes necessary around the variables?

Much appreciated
630111
 
In your shell man page take a look at 'shell quoting mechanism', 'variable substitution', 'IFS', 'for .. in', ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top