From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96079346819429.tru64-unix-managers.marc@archive.invalid> From: Danielle Georgette Date: Fri, 05 May 2000 07:16:10 +0000 To: tru64-unix-managers Subject: stupid scripting question X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96079346819429 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. | +---------------------------------------------------------------------+