<?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 Scripting in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006118#M773771</link>
    <description>dead horse, but still...&lt;BR /&gt;&lt;BR /&gt;System forks a process.&lt;BR /&gt;Find for a handful files, slow for thousands.&lt;BR /&gt;Personally I prefer the perl rename buildin:&lt;BR /&gt;&lt;BR /&gt;For example, with the shell finding the candidate files:&lt;BR /&gt;&lt;BR /&gt;perl -e 'while ($f = shift @ARGV) { $_ = $f; s/.tmp$/.xxx/; rename $f,$_ }' *.tmp&lt;BR /&gt;&lt;BR /&gt;Other example with perl's glob finding the files....&lt;BR /&gt;&lt;BR /&gt;perl -e 'while (&amp;lt;*.tmp&amp;gt;) { $old = $_; s/.tmp$/.xxx/; rename $old,$_ }'&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
    <pubDate>Sun, 01 Oct 2006 16:21:47 GMT</pubDate>
    <dc:creator>Hein van den Heuvel</dc:creator>
    <dc:date>2006-10-01T16:21:47Z</dc:date>
    <item>
      <title>Shell Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006112#M773765</link>
      <description>Hi &lt;BR /&gt;&lt;BR /&gt;Any body help me in solving the issue&lt;BR /&gt;there are lot of files with .txt extension inside my folder.I want to create a script such that all the files ending with .txt needs to convert into .xls &lt;BR /&gt;&lt;BR /&gt;The shell may be bash or any .NO PROBLEM&lt;BR /&gt;&lt;BR /&gt;Anybody Help me pls&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 29 Sep 2006 06:07:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006112#M773765</guid>
      <dc:creator>Virumandi</dc:creator>
      <dc:date>2006-09-29T06:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006113#M773766</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I believe you want to rename those files instead of convert.&lt;BR /&gt;If all .txt files are in the same directory:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;for fn in *.txt&lt;BR /&gt;do &lt;BR /&gt;   newfn=`echo $fn|sed 's/txt/xls/'`&lt;BR /&gt;   mv $fn $newfn&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Yang&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 29 Sep 2006 06:20:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006113#M773766</guid>
      <dc:creator>Yang Qin_1</dc:creator>
      <dc:date>2006-09-29T06:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006114#M773767</link>
      <description>That's funny!&lt;BR /&gt;&lt;BR /&gt;I actually use this exact problem as one of my interview questions...&lt;BR /&gt;&lt;BR /&gt;(correct answer, btw)&lt;BR /&gt;&lt;BR /&gt;Doug</description>
      <pubDate>Fri, 29 Sep 2006 08:32:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006114#M773767</guid>
      <dc:creator>Doug O'Leary</dc:creator>
      <dc:date>2006-09-29T08:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006115#M773768</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm soory but I must say that Yangs solution is not correct:&lt;BR /&gt;&lt;BR /&gt;Having a file named&lt;BR /&gt;fn=allmytxtbooks.txt&lt;BR /&gt;newfn=`echo $fn|sed 's/txt/xls/'`&lt;BR /&gt;&lt;BR /&gt;will lead to&lt;BR /&gt;allmyxlsbooks.txt&lt;BR /&gt;&lt;BR /&gt;I suggest plain shell builtins, so no extra process is needed:&lt;BR /&gt;&lt;BR /&gt;for fn in *.txt&lt;BR /&gt;do&lt;BR /&gt;  mv $fn ${fn%*.txt}.xls&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Error checking is left to the reader as an exercise :-)&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Sun, 01 Oct 2006 05:35:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006115#M773768</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-10-01T05:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006116#M773769</link>
      <description>If you are in the folder where the *.txt files are...&lt;BR /&gt;&lt;BR /&gt;# ls -1 *.txt | awk -F. '{system("mv "$0" "$1".xls")}'</description>
      <pubDate>Sun, 01 Oct 2006 15:40:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006116#M773769</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-10-01T15:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006117#M773770</link>
      <description>Wrong answer at an interview :)&lt;BR /&gt;&lt;BR /&gt;The correct answer would be a new question:&lt;BR /&gt;&lt;BR /&gt;Only at the current level, or recursive from the current folder?&lt;BR /&gt;And is the .txt extension case sensitive or not?&lt;BR /&gt;And are the .txt file containing CSV data, and do they have to be converted to real xls, or is a name change enough?&lt;BR /&gt;And should the new axtension match the casing of the old extension, or should it be all upper or lower case?&lt;BR /&gt;Are empty file to be renamed too? (empty .txt is valid text, empty .xls is not valid M$ Excel)&lt;BR /&gt;What is the host system, and should the script be portable (rename commands on VMS, M$Win, and *nix are quite different)&lt;BR /&gt;&lt;BR /&gt;Too many questions to make a correct answer to this question.&lt;BR /&gt;&lt;BR /&gt;$ perl -MFile::Find -MFile::Copy -e'find(sub{-s&amp;amp;&amp;amp;m/\.txt$/i or return;($n=$_)=~s/txt$/xls/i;move$_,$n},".")'&lt;BR /&gt;&lt;BR /&gt;Addresses all above problems in one line.&lt;BR /&gt;Analysis is left an excercise to the reader.&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Sun, 01 Oct 2006 16:16:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006117#M773770</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-10-01T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006118#M773771</link>
      <description>dead horse, but still...&lt;BR /&gt;&lt;BR /&gt;System forks a process.&lt;BR /&gt;Find for a handful files, slow for thousands.&lt;BR /&gt;Personally I prefer the perl rename buildin:&lt;BR /&gt;&lt;BR /&gt;For example, with the shell finding the candidate files:&lt;BR /&gt;&lt;BR /&gt;perl -e 'while ($f = shift @ARGV) { $_ = $f; s/.tmp$/.xxx/; rename $f,$_ }' *.tmp&lt;BR /&gt;&lt;BR /&gt;Other example with perl's glob finding the files....&lt;BR /&gt;&lt;BR /&gt;perl -e 'while (&amp;lt;*.tmp&amp;gt;) { $old = $_; s/.tmp$/.xxx/; rename $old,$_ }'&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Sun, 01 Oct 2006 16:21:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006118#M773771</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-10-01T16:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006119#M773772</link>
      <description>Holy crap!  Some of you, procura especially, read *way* too much into a question.&lt;BR /&gt;&lt;BR /&gt;It's the correct answer and gets the information I'm looking for in the intervew - specifically, can the person do a loop and does he or she know that you can't simply mv *.txt *.xls...&lt;BR /&gt;&lt;BR /&gt;I did catch the fact that it'd catch xls in the middle of the filename; my usual way to do this is to use ${f%.*} just to strip off the extension.  I would expect an admin that's working this problem to know his data; meaning he'd know if there was an xls in the middle of a set of filenames...&lt;BR /&gt;&lt;BR /&gt;Since it's one question out of many, I'm sure I'll get whether or not the guy has the requisite attention to detail as well...&lt;BR /&gt;&lt;BR /&gt;As for the rest of the answers, yet another proof that there's always multiple ways to solve problems in UNIX...  Personally, I'd think using perl for the problem as stated would be akin to killing a fly with a small thermonuclear device, but if it works, have at it...&lt;BR /&gt;&lt;BR /&gt;Doug</description>
      <pubDate>Mon, 02 Oct 2006 14:39:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006119#M773772</guid>
      <dc:creator>Doug O'Leary</dc:creator>
      <dc:date>2006-10-02T14:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006120#M773773</link>
      <description>Holy crap!  Some of you, procura especially, read *way* too much into a question.&lt;BR /&gt;&lt;BR /&gt;It's the correct answer and gets the information I'm looking for in the intervew - specifically, can the person do a loop and does he or she know that you can't simply mv *.txt *.xls...&lt;BR /&gt;&lt;BR /&gt;I did catch the fact that it'd match xls in the middle of the filename; The better answer given is my usual way to do this; use ${f%.*} just to strip off the extension.  It does, however, do what the OP requested... I would expect an admin that's working this problem to know his data; meaning he'd know if there was an xls in the middle of a set of filenames...&lt;BR /&gt;&lt;BR /&gt;Since it's one question out of many, I'm sure I'll get whether or not the guy has the requisite attention to detail as well...&lt;BR /&gt;&lt;BR /&gt;As for the rest of the answers, yet another proof that there's always multiple ways to solve problems in UNIX...  Personally, I'd think using perl for the problem as stated would be akin to killing a fly with a small thermonuclear device, but if it works, have at it, although the awk solution is interesting...  I never think to use awk that way..&lt;BR /&gt;&lt;BR /&gt;Doug&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 02 Oct 2006 14:53:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006120#M773773</guid>
      <dc:creator>Doug O'Leary</dc:creator>
      <dc:date>2006-10-02T14:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006121#M773774</link>
      <description>Holy crap!  Some of you, procura especially, read *way* too much into a question.&lt;BR /&gt;&lt;BR /&gt;It's the correct answer and gets the information I'm looking for in the intervew - specifically, can the person do a loop and does he or she know that you can't simply mv *.txt *.xls...&lt;BR /&gt;&lt;BR /&gt;I did catch the fact that it'd match xls in the middle of the filename; The better answer given is my usual way to do this; use ${f%.*} just to strip off the extension.  It does, however, do what the OP requested... I would expect an admin that's working this problem to know his data; meaning he'd know if there was an xls in the middle of a set of filenames...&lt;BR /&gt;&lt;BR /&gt;Since it's one question out of many, I'm sure I'll get whether or not the guy has the requisite attention to detail as well...&lt;BR /&gt;&lt;BR /&gt;As for the rest of the answers, yet another proof that there's always multiple ways to solve problems in UNIX...  Personally, I'd think using perl for the problem as stated would be akin to killing a fly with a small thermonuclear device, but if it works, have at it (although the awk solution is interesting).  &lt;BR /&gt;&lt;BR /&gt;Doug&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 02 Oct 2006 14:55:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006121#M773774</guid>
      <dc:creator>Doug O'Leary</dc:creator>
      <dc:date>2006-10-02T14:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006122#M773775</link>
      <description>sorry for the multiple responses... I seem to be having problems accessing itrc site...&lt;BR /&gt;&lt;BR /&gt;Doug</description>
      <pubDate>Mon, 02 Oct 2006 15:06:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006122#M773775</guid>
      <dc:creator>Doug O'Leary</dc:creator>
      <dc:date>2006-10-02T15:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006123#M773776</link>
      <description>Doug, no problem. It of course depends on which environment you work in.&lt;BR /&gt;My environment arises the *need* to be portable across OS's (HP-UX, AIX, Linux, Cygwin, Win32), and accross databases (Oracle, Unify, postgres, Mysql), so you learn to program in a very defensive style, and never use system calls if either modules or builtins are available that enable you to do the same in a portable way.&lt;BR /&gt;&lt;BR /&gt;My job is to be alert to any of these hidden questions and problems in questions from customers. "Can you please do A for me?" And they mean "B", but we should have known, as they always do so :) (wink wink)&lt;BR /&gt;&lt;BR /&gt;If I interview someone on unix knowledge, I most of the time do not expect a `real' answer. I expect either the questions I asked, or a question like "what does the company prefer? bash, awk, sed, perl, csh, python?"&lt;BR /&gt;As Hein said: It's a dead horse. There are a zillion options to `fix' it or deal with it. It's just the question of how to do it reliable and the way no new errors arise.&lt;BR /&gt;&lt;BR /&gt;Happy hacking!&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Mon, 02 Oct 2006 16:04:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006123#M773776</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-10-02T16:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006124#M773777</link>
      <description>Thanks to all of you...&lt;BR /&gt;The query has been resolved a little Earlier..&lt;BR /&gt;&lt;BR /&gt;But I didnt updated the Ticket.But however I found that it became one of the interesting topic for the people to Talk..&lt;BR /&gt;&lt;BR /&gt;Good...&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Suseendran .A</description>
      <pubDate>Thu, 05 Oct 2006 23:43:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-scripting/m-p/5006124#M773777</guid>
      <dc:creator>Virumandi</dc:creator>
      <dc:date>2006-10-05T23:43:25Z</dc:date>
    </item>
  </channel>
</rss>

