<?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: Advanced scripting in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/advanced-scripting/m-p/2921694#M3870</link>
    <description>Thanks Alot, while I didn't deplore your sujjestions as is, they really helped me figure out how to write the required script.</description>
    <pubDate>Mon, 10 Mar 2003 09:34:49 GMT</pubDate>
    <dc:creator>Edward_12</dc:creator>
    <dc:date>2003-03-10T09:34:49Z</dc:date>
    <item>
      <title>Advanced scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/advanced-scripting/m-p/2921690#M3866</link>
      <description>Dear Collegues;&lt;BR /&gt;&lt;BR /&gt;I have a listing of files as:&lt;BR /&gt;-rw-rw-r--   1 bit    abs     19 Mar  3 09:55 BRF.200302.TXT1&lt;BR /&gt;-rw-rw-r--   1 bit    abs     88 Mar  3 09:56 BRF.200302.TXT2&lt;BR /&gt;-rw-rw-r--   1 bit    abs     60 Mar  3 09:56 BRF.200302.TXT3&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;I want to write a script called "rname.sh" that changes '.' to '_' for all files at once and then call another script "prcess.sh' on each renamed file .&lt;BR /&gt;&lt;BR /&gt;This script may be called as $rname.sh BRF.200302* or $rname.sh BRF.*&lt;BR /&gt;&lt;BR /&gt;So far I do all steps one at a time manually.&lt;BR /&gt;&lt;BR /&gt;Thanks for you help.&lt;BR /&gt;Regards;&lt;BR /&gt;Edward</description>
      <pubDate>Fri, 07 Mar 2003 04:38:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/advanced-scripting/m-p/2921690#M3866</guid>
      <dc:creator>Edward_12</dc:creator>
      <dc:date>2003-03-07T04:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: Advanced scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/advanced-scripting/m-p/2921691#M3867</link>
      <description>here is a snippet. put in the script and run.&lt;BR /&gt;&lt;BR /&gt;for i in `ls -1`&lt;BR /&gt;do&lt;BR /&gt;   mv $i `echo $i | sed 's/\./_/g'`&lt;BR /&gt;done.&lt;BR /&gt;&lt;BR /&gt;hth&lt;BR /&gt;-balaji</description>
      <pubDate>Fri, 07 Mar 2003 08:32:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/advanced-scripting/m-p/2921691#M3867</guid>
      <dc:creator>Balaji N</dc:creator>
      <dc:date>2003-03-07T08:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: Advanced scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/advanced-scripting/m-p/2921692#M3868</link>
      <description>similar as last post but i'll post it anyways :)&lt;BR /&gt;(rname.sh)&lt;BR /&gt;&lt;BR /&gt;#! /bin/bash&lt;BR /&gt;&lt;BR /&gt;export PATH=$PATH:.&lt;BR /&gt;&lt;BR /&gt;for i in $(ls BRF*)&lt;BR /&gt;do&lt;BR /&gt;FNAME=$(echo $i|sed -e 's/\./_/g')&lt;BR /&gt;&lt;BR /&gt;mv $i $FNAME&lt;BR /&gt;prcess.sh $FNAME&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Fri, 07 Mar 2003 08:42:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/advanced-scripting/m-p/2921692#M3868</guid>
      <dc:creator>Bjoern Myrland</dc:creator>
      <dc:date>2003-03-07T08:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: Advanced scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/advanced-scripting/m-p/2921693#M3869</link>
      <description>Given that you want to pass the file-names on the command line, then you'll need to do something slightly different to what has been said.&lt;BR /&gt;&lt;BR /&gt;I'll grab the previous script, and modify it to use command-line given arguments:&lt;BR /&gt;&lt;BR /&gt;------------------------------&lt;BR /&gt;#!/bin/bash &lt;BR /&gt;&lt;BR /&gt;while [ ! -z "$1" ]&lt;BR /&gt;do &lt;BR /&gt;FNAME=$(echo $1|sed -e 's/\./_/g') &lt;BR /&gt;&lt;BR /&gt;mv $1 $FNAME &lt;BR /&gt;prcess.sh $FNAME &lt;BR /&gt;shift&lt;BR /&gt;done&lt;BR /&gt;------------------------------&lt;BR /&gt;&lt;BR /&gt;As you are passing it the file-name glob, the shell will automatically expand it, and just list a whole long list of file-names.&lt;BR /&gt;&lt;BR /&gt;The 'while', coupled with the 'shift' will keep looping around until it's worked it's way through all of the arguments.&lt;BR /&gt;&lt;BR /&gt;Instead of checking if the string "$1" is not empty (! -z), we could could instead check to see if the file exists (-f), or if it's readable (-r), or some other check.&lt;BR /&gt;&lt;BR /&gt;The 'PATH' is un-necessary (infact could be set explicitly to "PATH=/bin", but..) so I removed it from the example.&lt;BR /&gt;&lt;BR /&gt;Hope this helps you.</description>
      <pubDate>Sun, 09 Mar 2003 23:13:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/advanced-scripting/m-p/2921693#M3869</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2003-03-09T23:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Advanced scripting</title>
      <link>https://community.hpe.com/t5/operating-system-linux/advanced-scripting/m-p/2921694#M3870</link>
      <description>Thanks Alot, while I didn't deplore your sujjestions as is, they really helped me figure out how to write the required script.</description>
      <pubDate>Mon, 10 Mar 2003 09:34:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/advanced-scripting/m-p/2921694#M3870</guid>
      <dc:creator>Edward_12</dc:creator>
      <dc:date>2003-03-10T09:34:49Z</dc:date>
    </item>
  </channel>
</rss>

