* stupid scripting question
@ 2000-05-05 7:16 Danielle Georgette
0 siblings, 0 replies; only message in thread
From: Danielle Georgette @ 2000-05-05 7:16 UTC (permalink / raw)
To: tru64-unix-managers
I am humilated to ask a rather simple scripting question, especially since I
saw someone ask this question within the last few months and can't rememer
(or refind) the answer. This is driving me nuts and I cant see the forest
for the trees .
Simple problem: I have a file text.txt containing space formatted text:
a1 a2 a3
b1 b2 b3
c1 c2 c3
etc, where each column is 10 spaces wide.
I want to replace all the text in the middle column with the characters xx.
#!/bin/ksh
typeset -L10 colA
typeset -L10 colB="xx"
typeset -L10 colC
touch newtext.txt
for i in `cat text.txt`
do
colA=`echo $i |cut -c 1-10`
colC=`echo $i|cut -c 20-30`
echo $colA$colB$colC >> newtext.txt
done
But my script is breaking up each input line into the three parts, so what I
see in the output is:
a1
xx
a3
b1
xx
b3
I guess it has something to do with ksh interpreting spaces in the line as
field seperators, but how can I suppress/alter the script to stop this
happening ? I guess it could be done (probably better) in awk, and any
answers such will be welcome - but i'd also love an explaination as to why
the above happens as well.
Thanks!
Danielle
+-----------------------------------+---------------------------------+
| Danielle Georgette | Unix is very user friendly, its |
| Unix Admin | just rather particular about |
| danielle.georgette@asx.com.au | who it makes friends with. |
+-----------------------------------+---------------------------------+
| All opinions are my own unless clearly stated otherwise. |
+---------------------------------------------------------------------+
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2000-05-05 7:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-05-05 7:16 stupid scripting question Danielle Georgette
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox