<?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 Help in script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4527686#M367765</link>
    <description>I need to write a script which renames the files starting with XM and just take XM off their resulting names. For example, lets say there is a file called XMtest1.txt. The script will take XM off and rename this file to test1.txt and places it in the same working directory.&lt;BR /&gt;&lt;BR /&gt;Any help will be highly appreciated.</description>
    <pubDate>Wed, 04 Nov 2009 16:34:46 GMT</pubDate>
    <dc:creator>Waqar Razi</dc:creator>
    <dc:date>2009-11-04T16:34:46Z</dc:date>
    <item>
      <title>Help in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4527686#M367765</link>
      <description>I need to write a script which renames the files starting with XM and just take XM off their resulting names. For example, lets say there is a file called XMtest1.txt. The script will take XM off and rename this file to test1.txt and places it in the same working directory.&lt;BR /&gt;&lt;BR /&gt;Any help will be highly appreciated.</description>
      <pubDate>Wed, 04 Nov 2009 16:34:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4527686#M367765</guid>
      <dc:creator>Waqar Razi</dc:creator>
      <dc:date>2009-11-04T16:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4527687#M367766</link>
      <description>Try this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;for NAME in XM*.txt&lt;BR /&gt;do&lt;BR /&gt;NEWNAME=$(echo ${NAME} | sed 's/^SM//g')&lt;BR /&gt;echo "${NAME} -- ${NEWNAME}"&lt;BR /&gt;mv ${NAME} ${NEWNAME}&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Wed, 04 Nov 2009 16:42:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4527687#M367766</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2009-11-04T16:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4527688#M367767</link>
      <description>&lt;!--!*#--&gt;Hi Waqar,&lt;BR /&gt;&lt;BR /&gt;You can also try this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;for FILE in `ll XM* | awk '{print$9}' | cut -c 3-`&lt;BR /&gt;do&lt;BR /&gt;mv XM${FILE} ${FILE}&lt;BR /&gt;done</description>
      <pubDate>Wed, 04 Nov 2009 17:16:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4527688#M367767</guid>
      <dc:creator>R.K. #</dc:creator>
      <dc:date>2009-11-04T17:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help in script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4527689#M367768</link>
      <description>&lt;!--!*#--&gt;&amp;gt;R.K.: You can also try this:&lt;BR /&gt;for FILE in `ll XM* | awk '{print$9}' | cut -c 3-`&lt;BR /&gt;&lt;BR /&gt;There is no need to use ll(1) vs ls(1).  The former is going to make the disk and NFS sweat by statting each file, you just want the name.&lt;BR /&gt;&lt;BR /&gt;If you are already using awk, no need to use cut(1).&lt;BR /&gt;&lt;BR /&gt;And you can improve on Patrick's sed by using a shell builtin:&lt;BR /&gt;for NAME in XM*; do&lt;BR /&gt;   NEWNAME=${NAME#XM}&lt;BR /&gt;   echo "${NAME} -- ${NEWNAME}"&lt;BR /&gt;   mv ${NAME} ${NEWNAME}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;If there is a chance there are no XM* files, you can do:&lt;BR /&gt;for NAME in $(ls XM* 2&amp;gt; /dev/null); do&lt;BR /&gt;   NEWNAME=${NAME#XM}&lt;BR /&gt;   echo "${NAME} -- ${NEWNAME}"&lt;BR /&gt;   mv ${NAME} ${NEWNAME}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Or just add:&lt;BR /&gt;   if [ "$NAME" = "XM*" ]; then break; fi</description>
      <pubDate>Thu, 05 Nov 2009 11:01:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-in-script/m-p/4527689#M367768</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-11-05T11:01:44Z</dc:date>
    </item>
  </channel>
</rss>

