<?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 scripting - awk in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950792#M115902</link>
    <description>Hi guys,&lt;BR /&gt;&lt;BR /&gt;I'm new to scripting and have simple question about a script I'm trying to do, wonder if someone can help?&lt;BR /&gt;&lt;BR /&gt;The script creates a temporary file containing a list of files I'm interested in, what I now want the script to do is mv those files to a different directory. I'm sure it's easy but I can't get my head around it!&lt;BR /&gt;&lt;BR /&gt;I've been trying with the following loop but no result:&lt;BR /&gt;&lt;BR /&gt;for i in `cat $LISTFILE | awk `{print $1}``    &lt;BR /&gt;do cp $i $OUTDIR                             &lt;BR /&gt;done            &lt;BR /&gt;&lt;BR /&gt;Can anyone see the problem or suggest something more elegant (but simple please!)&lt;BR /&gt;&lt;BR /&gt;Thanks in advance!                               &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 14 Apr 2003 14:14:54 GMT</pubDate>
    <dc:creator>Rudeboy_1</dc:creator>
    <dc:date>2003-04-14T14:14:54Z</dc:date>
    <item>
      <title>scripting - awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950792#M115902</link>
      <description>Hi guys,&lt;BR /&gt;&lt;BR /&gt;I'm new to scripting and have simple question about a script I'm trying to do, wonder if someone can help?&lt;BR /&gt;&lt;BR /&gt;The script creates a temporary file containing a list of files I'm interested in, what I now want the script to do is mv those files to a different directory. I'm sure it's easy but I can't get my head around it!&lt;BR /&gt;&lt;BR /&gt;I've been trying with the following loop but no result:&lt;BR /&gt;&lt;BR /&gt;for i in `cat $LISTFILE | awk `{print $1}``    &lt;BR /&gt;do cp $i $OUTDIR                             &lt;BR /&gt;done            &lt;BR /&gt;&lt;BR /&gt;Can anyone see the problem or suggest something more elegant (but simple please!)&lt;BR /&gt;&lt;BR /&gt;Thanks in advance!                               &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Apr 2003 14:14:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950792#M115902</guid>
      <dc:creator>Rudeboy_1</dc:creator>
      <dc:date>2003-04-14T14:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: scripting - awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950793#M115903</link>
      <description>I see a couple of mistakes in the script - but i wonder if those are causing the problem. here's my corrected version of your script anyhow -&lt;BR /&gt;&lt;BR /&gt;# define LISTFILE and OUTDIR&lt;BR /&gt;LISTFILE=/tmp/abc.txt &lt;BR /&gt;OUTDIR=/target_dir&lt;BR /&gt;&lt;BR /&gt;for file in `cat $LISTFILE | awk '{print $1}'` # notice presence of both grave accent and single quotes here&lt;BR /&gt;do&lt;BR /&gt;  cp $i $OUTDIR&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;BR /&gt;&lt;BR /&gt;should work fine now.&lt;BR /&gt;&lt;BR /&gt;- ramd.</description>
      <pubDate>Mon, 14 Apr 2003 14:20:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950793#M115903</guid>
      <dc:creator>Ramkumar Devanathan</dc:creator>
      <dc:date>2003-04-14T14:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: scripting - awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950794#M115904</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Here is one way to do it:&lt;BR /&gt;&lt;BR /&gt;for i in $(awk '{print $1}' $LISTFILE);&lt;BR /&gt;do&lt;BR /&gt;cp $i $OUTDIR&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The $() executes a command just like the back ticks do.&lt;BR /&gt;&lt;BR /&gt;If your LISTFILE just contains the file names and no other fields, you could do the for line like this:&lt;BR /&gt;&lt;BR /&gt;for i in $(&amp;lt;$LISTFILE)&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Apr 2003 14:20:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950794#M115904</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-04-14T14:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: scripting - awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950795#M115905</link>
      <description>A command does exist to copy a set of files from a given list to another directory. That would be "cpio". Assuming your list of filenames are not absolute paths (ie begin with a "/"), then you can do the following-&lt;BR /&gt;&lt;BR /&gt;cd fromdirectory&lt;BR /&gt;cat $LISTFILE | cpio -pd $OUTDIR&lt;BR /&gt;&lt;BR /&gt;Do a "man cpio" to see if it can be used for your task.&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Mon, 14 Apr 2003 14:21:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950795#M115905</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2003-04-14T14:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: scripting - awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950796#M115906</link>
      <description>And Rudeboy that's the difference between royalty and grads... see their really elegant solutions. &lt;BR /&gt;&lt;BR /&gt;- ramd.</description>
      <pubDate>Mon, 14 Apr 2003 14:23:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950796#M115906</guid>
      <dc:creator>Ramkumar Devanathan</dc:creator>
      <dc:date>2003-04-14T14:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: scripting - awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950797#M115907</link>
      <description>Hi!!&lt;BR /&gt;&lt;BR /&gt;Make sure LISTFILE and OUTDIR are defined. Also if the filenames are single names I will take the awk command out.&lt;BR /&gt;&lt;BR /&gt;DR</description>
      <pubDate>Mon, 14 Apr 2003 14:24:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950797#M115907</guid>
      <dc:creator>Dario_1</dc:creator>
      <dc:date>2003-04-14T14:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: scripting - awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950798#M115908</link>
      <description>Cool, job done thanks for the help.</description>
      <pubDate>Mon, 14 Apr 2003 14:37:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950798#M115908</guid>
      <dc:creator>Rudeboy_1</dc:creator>
      <dc:date>2003-04-14T14:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: scripting - awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950799#M115909</link>
      <description>#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;safe_copy()&lt;BR /&gt;{&lt;BR /&gt;for i in $(awk '{print $1}' $LISTFILE); &lt;BR /&gt;do &lt;BR /&gt;     cp $i $OUTDIR&lt;BR /&gt;     if [ $? = 0 ]&lt;BR /&gt;        then&lt;BR /&gt;        printf "$i copied succesfully to $OUTDIR\n"&lt;BR /&gt;        else&lt;BR /&gt;        printf "$i failed to copy\n"&lt;BR /&gt;     fi&lt;BR /&gt;done&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;email_results()&lt;BR /&gt;{&lt;BR /&gt;SUBJECT=$*&lt;BR /&gt;USERS="youremailaddress@where-ever.net"&lt;BR /&gt;mailx -s "${SUBJECT}" $USERS &amp;lt;${OUTFILE}&lt;BR /&gt;}&lt;BR /&gt;cleanup()&lt;BR /&gt;{&lt;BR /&gt;rm /tmp/$$.tmp&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;#&lt;BR /&gt;# Main&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;trap 'cleanup' 0&lt;BR /&gt;&lt;BR /&gt;OUTDIR=&lt;BR /&gt;LISTFILE=&lt;BR /&gt;OUTFILE=$$.tmp&lt;BR /&gt;&lt;BR /&gt;save_copy | tee -a $OUTFILE&lt;BR /&gt;email_results&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;___END___&lt;BR /&gt;&lt;BR /&gt;enjoy the freedom of ITRC &lt;BR /&gt;&lt;BR /&gt;peace&lt;BR /&gt;Donny</description>
      <pubDate>Mon, 14 Apr 2003 21:39:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950799#M115909</guid>
      <dc:creator>Donny Jekels</dc:creator>
      <dc:date>2003-04-14T21:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: scripting - awk</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950800#M115910</link>
      <description>Wow, by the time I am posting you got the answers. This group is very fast &amp;amp; furious(all are like Bullet Monk).&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Zafar</description>
      <pubDate>Mon, 14 Apr 2003 21:59:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-awk/m-p/2950800#M115910</guid>
      <dc:creator>Zafar A. Mohammed_1</dc:creator>
      <dc:date>2003-04-14T21:59:06Z</dc:date>
    </item>
  </channel>
</rss>

