<?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 Re: Putting spaces into a cut command output in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027717#M909976</link>
    <description>Thank you all for your help.  This has been bugging me all day.</description>
    <pubDate>Fri, 18 Jul 2003 18:40:18 GMT</pubDate>
    <dc:creator>Wayne Clay</dc:creator>
    <dc:date>2003-07-18T18:40:18Z</dc:date>
    <item>
      <title>Putting spaces into a cut command output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027708#M909967</link>
      <description>This may seem like a silly question, but I am cutting charaters from a flat file and there are no field seperators in the flat file. I want to grep for a piece of data from a line and cut data out of that line and put spaces between the data that is pulled out.  Does anyone know of a way to do this?</description>
      <pubDate>Fri, 18 Jul 2003 17:40:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027708#M909967</guid>
      <dc:creator>Wayne Clay</dc:creator>
      <dc:date>2003-07-18T17:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: Putting spaces into a cut command output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027709#M909968</link>
      <description>using awk you can change any character into a field seperators....&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;awk -F. '{print $1,$2,$3}'&lt;BR /&gt;&lt;BR /&gt;will put spaces between all characters in your file&lt;BR /&gt;&lt;BR /&gt;(you'll need to put the appropriate number of fields in ...not just $1,$2,$3)</description>
      <pubDate>Fri, 18 Jul 2003 17:48:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027709#M909968</guid>
      <dc:creator>John Meissner</dc:creator>
      <dc:date>2003-07-18T17:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Putting spaces into a cut command output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027710#M909969</link>
      <description>seems like your just looking to replace a string with spaces, in which case sed should work just fine&lt;BR /&gt;&lt;BR /&gt;cat your file | sed 's/ data /      /g' #&amp;gt; another file&lt;BR /&gt;&lt;BR /&gt;that is data with a leading and trailing space which means it won't catch if data is at the beginning or end of the line. and 6 spaces&lt;BR /&gt;&lt;BR /&gt;sed 's/^data /     /' #for beginning of line&lt;BR /&gt;sed 's/ data$/     /' #for end of line&lt;BR /&gt;&lt;BR /&gt;these use 5 spaces.&lt;BR /&gt;&lt;BR /&gt;altogether&lt;BR /&gt;&lt;BR /&gt;sed -e 's/ data /     /g' -e 's/^data /    /' -e 's/ data$/    /' &lt;BR /&gt;&lt;BR /&gt;just replace data with your characters and put in the appropriate number of spaces.</description>
      <pubDate>Fri, 18 Jul 2003 17:50:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027710#M909969</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-07-18T17:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Putting spaces into a cut command output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027711#M909970</link>
      <description>oops... sorry... no points for my previous post... didn't work ... I'll get the correct syntax to you in just a minute&lt;BR /&gt;</description>
      <pubDate>Fri, 18 Jul 2003 17:53:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027711#M909970</guid>
      <dc:creator>John Meissner</dc:creator>
      <dc:date>2003-07-18T17:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: Putting spaces into a cut command output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027712#M909971</link>
      <description>The naive approach would do something like this:&lt;BR /&gt;&lt;BR /&gt;cut -c 1-2,5-10 &amp;lt; myfile | while read A B&lt;BR /&gt;do&lt;BR /&gt;  echo "${A} ${B}"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;but this will not work because cut will put everying in the list argument in ${A}.&lt;BR /&gt;&lt;BR /&gt;This will work:&lt;BR /&gt;cat myfile | while read X&lt;BR /&gt;  do&lt;BR /&gt;     A=$(echo ${X} | cut -c 1-2)&lt;BR /&gt;     B=$(echo ${X} | cut -c 5-10)&lt;BR /&gt;     echo "${A} ${B}"&lt;BR /&gt;  done&lt;BR /&gt;&lt;BR /&gt;A better approach would be to create an awk script, my.awk&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;  a = substr($0,1,2)&lt;BR /&gt;  b = substr($0,5,6)&lt;BR /&gt;  printf("%s %s\n",a,b)&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;then invoke it as&lt;BR /&gt;awk -f my.awk myfile&lt;BR /&gt;</description>
      <pubDate>Fri, 18 Jul 2003 17:58:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027712#M909971</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-07-18T17:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: Putting spaces into a cut command output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027713#M909972</link>
      <description>What i'm trying to do is this:&lt;BR /&gt;&lt;BR /&gt;I have a file with lines in it with data like this&lt;BR /&gt;0540000560583221010907500007477660505020711000000006&lt;BR /&gt;and I want to pull out charaters 13-23 and 44-52 with spaces between the first set of charaters and the last set.  Also, the last set is the end of the line.</description>
      <pubDate>Fri, 18 Jul 2003 17:59:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027713#M909972</guid>
      <dc:creator>Wayne Clay</dc:creator>
      <dc:date>2003-07-18T17:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: Putting spaces into a cut command output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027714#M909973</link>
      <description>which would mean a script something like this&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;string="data"&lt;BR /&gt;numchar=${#string}&lt;BR /&gt;spaces=""&lt;BR /&gt;&lt;BR /&gt;x=0&lt;BR /&gt;while (( $x &amp;lt; $numchar ))&lt;BR /&gt;do&lt;BR /&gt;spaces="$spaces "&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;cat yourfile |&lt;BR /&gt;sed -e 's/ '$string' / '$spaces' /g'     -e 's/^'$string' / '$spaces' /'      -e 's/ '$string'$/ '$spaces'/'   &amp;gt; newfile&lt;BR /&gt;&lt;BR /&gt;mv newfile yourfile&lt;BR /&gt;</description>
      <pubDate>Fri, 18 Jul 2003 18:03:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027714#M909973</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-07-18T18:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: Putting spaces into a cut command output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027715#M909974</link>
      <description>Sorry about my first post... I was thinking about something else... but this will work according to the information that you put in your last post&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;cat file |&lt;BR /&gt;while read line&lt;BR /&gt;do&lt;BR /&gt;sting1=$(echo $line | cut 13-23)&lt;BR /&gt;string2=$(echo $line | cut 44-52)&lt;BR /&gt;echo $string1 $string2 &amp;gt;&amp;gt; newfile&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 18 Jul 2003 18:08:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027715#M909974</guid>
      <dc:creator>John Meissner</dc:creator>
      <dc:date>2003-07-18T18:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Putting spaces into a cut command output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027716#M909975</link>
      <description>if i think what you're looking right, clay's suggestion is probably best&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;cat yourfile |&lt;BR /&gt;awk '{&lt;BR /&gt;a = substr($0,13,11) &lt;BR /&gt;b = substr($0,44,9) &lt;BR /&gt;printf("%s %s\n",a,b) &lt;BR /&gt;}'&lt;BR /&gt;&lt;BR /&gt;sorry about the misdirected  posts</description>
      <pubDate>Fri, 18 Jul 2003 18:18:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027716#M909975</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-07-18T18:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: Putting spaces into a cut command output</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027717#M909976</link>
      <description>Thank you all for your help.  This has been bugging me all day.</description>
      <pubDate>Fri, 18 Jul 2003 18:40:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/putting-spaces-into-a-cut-command-output/m-p/3027717#M909976</guid>
      <dc:creator>Wayne Clay</dc:creator>
      <dc:date>2003-07-18T18:40:18Z</dc:date>
    </item>
  </channel>
</rss>

