tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: Danielle Georgette <Danielle.Georgette () asx ! com ! au>
To: tru64-unix-managers
Subject: stupid scripting question
Date: Fri, 05 May 2000 07:16:10 +0000	[thread overview]
Message-ID: <96079346819429.tru64-unix-managers.marc@archive.invalid> (raw)


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

                 reply	other threads:[~2000-05-05  7:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox