Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!unisoft!fai!sequent!lugnut From: lugnut@sequent.UUCP (Don Bolton) Newsgroups: comp.unix.shell Subject: Re: adjusting string var to fixed length Message-ID: <61410@sequent.UUCP> Date: 5 Jun 91 20:08:51 GMT References: <1991Jun3.181447.12656@mnemosyne.cs.du.edu> Reply-To: lugnut@sequent.UUCP (Don Bolton) Organization: Sequent Computer Systems, Inc Lines: 17 In article <1991Jun3.181447.12656@mnemosyne.cs.du.edu> rchattam@isis.cs.du.edu (King Chattam) writes: >Netters, > I have a shell var (length 0 to 10), which I want always to be output >to a file as fixed length 10. I tried sed, awk etc to adjust the string >length to 10, but did not work. > Awks printf("%10s%s\n",$1,"|") Or some such syntax should put out a "|" symbol at the 11th pos. (am not at my real desk to check syntax out) Or you could get more involved and use length to count the characters in your variable and a while i <= 10 print " "; ++i the tools are there anyhow. > Could someone please tell me how blanks can be appended to string vars >to make it fixed length? >rchattam@nyx.cs.du.edu >Thanks