<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Duplicating Characters in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337523#M712482</link>
    <description>Can anyone tell me if there is an easy way to echo out a given number of duplicate characters to the screen (or even better, into a variable) !&lt;BR /&gt;&lt;BR /&gt;I want to be able to echo a set number of spaces based upon the width of the screen as set in ${LINES}, from within a ksh script.&lt;BR /&gt;&lt;BR /&gt;I've tried a quick counting loop to build the text, but this seems to really slow up my script.&lt;BR /&gt;&lt;BR /&gt;I know there is probably a good way to do this with awk/sed etc, but I just cannot think of the best way to do it !!&lt;BR /&gt;&lt;BR /&gt;Any help will be greatly appreciated (as always !!)&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Paul.&lt;BR /&gt;</description>
    <pubDate>Wed, 21 Jul 2004 09:43:53 GMT</pubDate>
    <dc:creator>Paul Murray_4</dc:creator>
    <dc:date>2004-07-21T09:43:53Z</dc:date>
    <item>
      <title>Duplicating Characters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337523#M712482</link>
      <description>Can anyone tell me if there is an easy way to echo out a given number of duplicate characters to the screen (or even better, into a variable) !&lt;BR /&gt;&lt;BR /&gt;I want to be able to echo a set number of spaces based upon the width of the screen as set in ${LINES}, from within a ksh script.&lt;BR /&gt;&lt;BR /&gt;I've tried a quick counting loop to build the text, but this seems to really slow up my script.&lt;BR /&gt;&lt;BR /&gt;I know there is probably a good way to do this with awk/sed etc, but I just cannot think of the best way to do it !!&lt;BR /&gt;&lt;BR /&gt;Any help will be greatly appreciated (as always !!)&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Paul.&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Jul 2004 09:43:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337523#M712482</guid>
      <dc:creator>Paul Murray_4</dc:creator>
      <dc:date>2004-07-21T09:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicating Characters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337524#M712483</link>
      <description>Spaces are particularly easy because you can use a printf field width.&lt;BR /&gt;&lt;BR /&gt;myvar=$(printf "%${LINES}s" " ")&lt;BR /&gt;&lt;BR /&gt;That uses the printf command with a blank string printed into a field of $LINES characters.</description>
      <pubDate>Wed, 21 Jul 2004 10:10:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337524#M712483</guid>
      <dc:creator>Mike Stroyan</dc:creator>
      <dc:date>2004-07-21T10:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicating Characters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337525#M712484</link>
      <description>Mike, what can I say .....&lt;BR /&gt;&lt;BR /&gt;YOU ARE A STAR !!!!!   &lt;BR /&gt;&lt;BR /&gt;Thanks !&lt;BR /&gt;Paul.&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Jul 2004 10:13:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337525#M712484</guid>
      <dc:creator>Paul Murray_4</dc:creator>
      <dc:date>2004-07-21T10:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicating Characters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337526#M712485</link>
      <description>sounds like something that might be done with printf&lt;BR /&gt;&lt;BR /&gt;this will right justify your text&lt;BR /&gt;&lt;BR /&gt;cat file |&lt;BR /&gt;while read text&lt;BR /&gt;do&lt;BR /&gt;printf '%${LINES}s\n' $text&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#print "x" number of spaces&lt;BR /&gt;printf '%${x}s' " "&lt;BR /&gt;&lt;BR /&gt;of course the important information of how many spaces (other then based on LINES) and where the spaces should be, you left out of your question.&lt;BR /&gt;&lt;BR /&gt;maybe if you provided some sample text to illustrate what your trying to accomplish better suggestions could be provided.&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Jul 2004 10:19:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337526#M712485</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-07-21T10:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicating Characters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337527#M712486</link>
      <description>&lt;BR /&gt;if it is only spaces you are after, then you are lucky, as printf from anywhere (awk, shell) can nicely do a variable length empty field:&lt;BR /&gt;&lt;BR /&gt;# awk 'END{printf ("test%*stest\n",40," ")}' /dev/null&lt;BR /&gt;&lt;BR /&gt;For long series of other characters PERL has a neat 'x' function&lt;BR /&gt;&lt;BR /&gt;#perl -e 'print "*"x10 . "\n"'&lt;BR /&gt;**********&lt;BR /&gt;# perl -e 'print "*"x20 . "\n"'&lt;BR /&gt;********************&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.</description>
      <pubDate>Wed, 21 Jul 2004 10:19:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337527#M712486</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2004-07-21T10:19:20Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicating Characters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337528#M712487</link>
      <description>Thanks Curt.  One small question, just to up-spec my own knowledge really .....&lt;BR /&gt;&lt;BR /&gt;If I wanted to print hash marks instead of spaces, what would I need to change ?&lt;BR /&gt;&lt;BR /&gt;Regs,&lt;BR /&gt;Paul.&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Jul 2004 10:22:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337528#M712487</guid>
      <dc:creator>Paul Murray_4</dc:creator>
      <dc:date>2004-07-21T10:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicating Characters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337529#M712488</link>
      <description>If I wanted to print hash marks instead of spaces, what would I need to change ?&lt;BR /&gt;&lt;BR /&gt;the easy answer is perl, where you could do:&lt;BR /&gt;print "#" x $num;&lt;BR /&gt;&lt;BR /&gt;but to avoiding calling perl for each line of your text, you'd want to do everything within perl or&lt;BR /&gt;&lt;BR /&gt;#make a long variable with hashes&lt;BR /&gt;# just pick a number bigger then your going to need&lt;BR /&gt;myvar=$(perl -e 'print "#" x 256;')&lt;BR /&gt;&lt;BR /&gt;then use printf within your shell script to truncate the variable to the length you want&lt;BR /&gt;&lt;BR /&gt;printf "%{Len}s" $myvar&lt;BR /&gt;&lt;BR /&gt;that way you'll only call perl once.&lt;BR /&gt;&lt;BR /&gt;of course a simply while loop might be even faster then calling perl&lt;BR /&gt;&lt;BR /&gt;x="#"&lt;BR /&gt;y=10&lt;BR /&gt;while (( y &amp;gt; 0 ))&lt;BR /&gt;do&lt;BR /&gt;x="$x$x"&lt;BR /&gt;y=$(( $y = 1 ))&lt;BR /&gt;done&lt;BR /&gt;# x is now a long string of #'s&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Jul 2004 10:43:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337529#M712488</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-07-21T10:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicating Characters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337530#M712489</link>
      <description>I hope you caught my mistake where&lt;BR /&gt;x="$x$x"&lt;BR /&gt;y=$(( $y = 1 ))&lt;BR /&gt;&lt;BR /&gt;should really be&lt;BR /&gt;&lt;BR /&gt;x="$x$x"&lt;BR /&gt;y=$(( $y - 1 ))&lt;BR /&gt;&lt;BR /&gt;and if your really doing some serious text formatting, using perl is the way to go. it is a feature rich tool which is so much better then the shell.  i.e. shell text formatting has just implemented the printf function in the past few years, where perl was designed for formattng text.&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Jul 2004 10:59:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337530#M712489</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-07-21T10:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicating Characters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337531#M712490</link>
      <description>Hi Curt,&lt;BR /&gt;&lt;BR /&gt;Thanks again for the help.  The text formatting part of the script is pretty minor, so I ended up cheating rather than using perl.&lt;BR /&gt;&lt;BR /&gt;MYVAR="$(echo "$(printf "%${LINES}s" " ")" | sed 's/ /\#/g')"&lt;BR /&gt;&lt;BR /&gt;Thanks again (to all !) for your help. &lt;BR /&gt;&lt;BR /&gt;Paul.</description>
      <pubDate>Wed, 21 Jul 2004 11:04:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337531#M712490</guid>
      <dc:creator>Paul Murray_4</dc:creator>
      <dc:date>2004-07-21T11:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicating Characters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337532#M712491</link>
      <description>sed is a rather heavy general-case tool for replacing characters.  The tr command specializes in it.&lt;BR /&gt;&lt;BR /&gt;MYVAR="$(printf %${LINES}s ' ' | tr ' ' '#')"</description>
      <pubDate>Wed, 21 Jul 2004 16:12:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337532#M712491</guid>
      <dc:creator>Mike Stroyan</dc:creator>
      <dc:date>2004-07-21T16:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicating Characters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337533#M712492</link>
      <description>Good call !!  Thanks Mike !</description>
      <pubDate>Thu, 22 Jul 2004 09:48:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/duplicating-characters/m-p/3337533#M712492</guid>
      <dc:creator>Paul Murray_4</dc:creator>
      <dc:date>2004-07-22T09:48:04Z</dc:date>
    </item>
  </channel>
</rss>

