<?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: shell script help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4348793#M344579</link>
    <description>I wish we could edit posts!!!&lt;BR /&gt;&lt;BR /&gt;If you struggle to awk for the brackets, try adding a "-b" option to the ls. This may print the octal value rather than the bracket. Again, give this ago, I am not in front of a unix box at present.</description>
    <pubDate>Sat, 31 Jan 2009 05:56:08 GMT</pubDate>
    <dc:creator>Mark McDonald_2</dc:creator>
    <dc:date>2009-01-31T05:56:08Z</dc:date>
    <item>
      <title>shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4348790#M344576</link>
      <description>Trying to do create a shell script that will do the following:&lt;BR /&gt;&lt;BR /&gt;run only if specific files are found in a directory. If files are found, then I need to fix them by removing bad characters only from the file names.  Wanted to replace these bad characters with a # so we can do a lookup for what the file should be renamed.  This lookup is inside another file. I'm trying to learn perl, but have not used it much.  Here's a better example(I hope)of what I'm stuck with.&lt;BR /&gt;&lt;BR /&gt;Files come in as &lt;BR /&gt;Payroll(1000171)20090112_163013.xml&lt;BR /&gt; &lt;BR /&gt;Add in the # so new file would be something like Payroll#1000171#20090112_163013.xml so then I could use &lt;BR /&gt;ls Payroll*.xml | awk -F# '{print $2}'to do the lookup on a text file for the correct field name.&lt;BR /&gt;#1000171# = 0218 &lt;BR /&gt;Once I have this match I'm not sure how to grab the correct match name out so I end up with the following...&lt;BR /&gt;Payroll_0218_20090112.xml&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks!</description>
      <pubDate>Fri, 30 Jan 2009 23:58:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4348790#M344576</guid>
      <dc:creator>hamlite42</dc:creator>
      <dc:date>2009-01-30T23:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4348791#M344577</link>
      <description>Just to clarify - you need to pull out what is in between the brackets and replace with another string.&lt;BR /&gt;&lt;BR /&gt;Not sure but off the top of my head:&lt;BR /&gt;&lt;BR /&gt;for FILE in `ls Payroll*.xml`&lt;BR /&gt;do&lt;BR /&gt;STRING=$(echo $FILE | awk -F"(" '{ print $2 }' | awk -F ")" '{ print $1 }')&lt;BR /&gt;#do the look up to get STRING2&lt;BR /&gt;&lt;BR /&gt;$NEWFILENAME=#do some more awking as above to create this.&lt;BR /&gt;mv $FILE $NEWFILENAME&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Saves putting the hashes in. Not sure whether the brackets should be quoted or escaped. You will have to experiment.</description>
      <pubDate>Sat, 31 Jan 2009 05:42:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4348791#M344577</guid>
      <dc:creator>Mark McDonald_2</dc:creator>
      <dc:date>2009-01-31T05:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4348792#M344578</link>
      <description>Squeeze this in to the above loop:&lt;BR /&gt;&lt;BR /&gt;$THEREST=4(echo $FILE|awk -F")" '{ print $2 }')&lt;BR /&gt;$NEWFILENAME="Payroll_"+$STRING2+"_"+$THEREST</description>
      <pubDate>Sat, 31 Jan 2009 05:45:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4348792#M344578</guid>
      <dc:creator>Mark McDonald_2</dc:creator>
      <dc:date>2009-01-31T05:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4348793#M344579</link>
      <description>I wish we could edit posts!!!&lt;BR /&gt;&lt;BR /&gt;If you struggle to awk for the brackets, try adding a "-b" option to the ls. This may print the octal value rather than the bracket. Again, give this ago, I am not in front of a unix box at present.</description>
      <pubDate>Sat, 31 Jan 2009 05:56:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4348793#M344579</guid>
      <dc:creator>Mark McDonald_2</dc:creator>
      <dc:date>2009-01-31T05:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4348794#M344580</link>
      <description>&lt;!--!*#--&gt;Assuming your field mapping file "FIELD" looks like this:&lt;BR /&gt;1000181 = 0219&lt;BR /&gt;1000171 = 0218&lt;BR /&gt;&lt;BR /&gt;And the number of files is small compared to records in FIELD.&lt;BR /&gt;&lt;BR /&gt;ls Payroll\(*\)*.xml |&lt;BR /&gt;   awk -F"[()]" -vFILE=FIELD '&lt;BR /&gt;{&lt;BR /&gt;   s0 = $0&lt;BR /&gt;   s1 = $1&lt;BR /&gt;   s2 = $2&lt;BR /&gt;   s3 = $3&lt;BR /&gt;   save_FS = FS&lt;BR /&gt;   FS = " "&lt;BR /&gt;   stat = "grep \"" s2 "\" " FILE | getline&lt;BR /&gt;   if (stat == 1)&lt;BR /&gt;      print "mv \"" s0 "\"", s1 "_" $3 "_" s3&lt;BR /&gt;   else&lt;BR /&gt;      print "echo \"Cannot rename", $0 "\""&lt;BR /&gt;   FS = save_FS&lt;BR /&gt;} '&lt;BR /&gt;&lt;BR /&gt;This produces output like:&lt;BR /&gt;========================================================&lt;BR /&gt;mv "Payroll(1000171)20090112_163013.xml" Payroll_0218_20090112_163013.xml&lt;BR /&gt;mv "Payroll(1000181)20090112_163013.xml" Payroll_0219_20090112_163013.xml&lt;BR /&gt;echo "Cannot rename Payroll(1000191)20090112_163013.xml"&lt;BR /&gt;&lt;BR /&gt;And then you can use a shell to execute the commands.</description>
      <pubDate>Sat, 31 Jan 2009 10:53:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/4348794#M344580</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-01-31T10:53:54Z</dc:date>
    </item>
  </channel>
</rss>

