<?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: Help with awk script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800433#M81780</link>
    <description>Hi Lisa:&lt;BR /&gt;&lt;BR /&gt;/NO_MORE_POINTS_PLEASE/&lt;BR /&gt;&lt;BR /&gt;I never meant for my bungled typing to receive points -- only the last of my corrections!&lt;BR /&gt;&lt;BR /&gt;The use of the last field (NF) in Andreas Voss' solution is the superior answer.  By using relative field numbers, like:&lt;BR /&gt;&lt;BR /&gt;# awk '{print "rm",$(NF-2)9;print "ln -s",$NF,$(NF-2)}' filein &amp;gt; fileout&lt;BR /&gt;&lt;BR /&gt;...you can handle input created by 'ls -l' or 'ls -ls' where the addition of the '-s' option adds another field and shifts the field containing the filename downstream.&lt;BR /&gt;&lt;BR /&gt;/NO_MORE_POINTS_PLEASE/&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Thu, 05 Sep 2002 16:38:48 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2002-09-05T16:38:48Z</dc:date>
    <item>
      <title>Help with awk script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800423#M81770</link>
      <description>Hi, well I did an oops. We use RCS to maintain version control on all our cobol programs and copy books, scripts, etc. Well we also use symbolic links to link a program in a customer directory to another customer directory. Well... we decided to move the RCS from 1 server to another, and rcp of course created a copy of the program instead of created the symbolic link. An oops I never thought of until now when I have over 600 links to recreate, including removing the now copied code. Thought I would post a help me as my awk scripting skills are not the best... The good news is , I did create a script that lists all the links, so just in case something would ahppen I do have a backup - basically a butt saver right now :)&lt;BR /&gt;What I am trying to do is use this file to 1st - delete the 1st file in the line, so we can remove the copy (which should be a link), 2nd recreate the symbolic link listed in this file (as the second file listed on the line is the actual code, the link needs to be recreated from that point to the 1st file listed on the line). Since I know there are some scripting God's out there, as I work on it, any input would be quite appreciated!!! I was going to attempt to use awk, using the '-&amp;gt;' as a field separator. Then put the 2nd filename 1st for the ln -s command to the second filename to relink.&lt;BR /&gt;Here is the format of the linklog file that lists 551 lines of all links within our customer directories, I am also attaching the entire file:&lt;BR /&gt;lrwxrwxrwx   1 382        15              50 Jan 18  2002 /opt/cs3000/pca/funded&lt;BR /&gt;/1004131/script/cnutr105.sh,v -&amp;gt; /opt/cs3000/pca/funded/W43392/script/cnutr105.sh,v&lt;BR /&gt;&lt;BR /&gt;ugh... If I get a solution and you are going to LA, I'll definitely buy you a beer!!! :)&lt;BR /&gt;Thanks!&lt;BR /&gt;Lisa&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Sep 2002 12:25:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800423#M81770</guid>
      <dc:creator>Lisa  Mauer</dc:creator>
      <dc:date>2002-09-05T12:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: Help with awk script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800424#M81771</link>
      <description>Hi Lisa:&lt;BR /&gt;&lt;BR /&gt;See if this fits your needs:&lt;BR /&gt;&lt;BR /&gt;awk '{print "rm",$5;print "ln -s",$7,$5}' filein &amp;gt; fileout&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 05 Sep 2002 12:44:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800424#M81771</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-09-05T12:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help with awk script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800425#M81772</link>
      <description>Hi Lisa,&lt;BR /&gt;&lt;BR /&gt;I have one way to do it.  Using your file of links (named links.txt and removed blank lines at the beginning and the end), I ran this awk command to create a file that will remove the first file and create the symlinks:&lt;BR /&gt;&lt;BR /&gt;awk '{printf("rm %s\nln -s %s %s\n", $9, $11, $9)}' links.txt &amp;gt;links.sh&lt;BR /&gt;&lt;BR /&gt;This creates the links.sh file, which looks like this (first couple of lines):&lt;BR /&gt;&lt;BR /&gt;head -4 links.sh&lt;BR /&gt;rm /opt/cs3000/pca/funded/1004131/cobol/PNBUT11F.CBL,v&lt;BR /&gt;ln -s /opt/cs3000/pca/funded/W43392/cobol/PNBUT11F.CBL,v /opt/cs3000/pca/funded/&lt;BR /&gt;1004131/cobol/PNBUT11F.CBL,v&lt;BR /&gt;rm /opt/cs3000/pca/funded/1004131/script/cnutr105.sh,v&lt;BR /&gt;ln -s /opt/cs3000/pca/funded/W43392/script/cnutr105.sh,v /opt/cs3000/pca/funded/&lt;BR /&gt;1004131/script/cnutr105.sh,v&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Does that look like what you are looking for?&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Sep 2002 12:44:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800425#M81772</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2002-09-05T12:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: Help with awk script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800426#M81773</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;here my quick and dirty awk:&lt;BR /&gt;&lt;BR /&gt;awk '{&lt;BR /&gt;f1=$(NF-2)&lt;BR /&gt;f2=$NF&lt;BR /&gt;print "rm " f1&lt;BR /&gt;print "ln -s " f2 " " f1&lt;BR /&gt;}' ls_file &amp;gt;link_recreate.sh&lt;BR /&gt;&lt;BR /&gt;then run sh link_recreate.sh&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Thu, 05 Sep 2002 12:45:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800426#M81773</guid>
      <dc:creator>Andreas Voss</dc:creator>
      <dc:date>2002-09-05T12:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help with awk script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800427#M81774</link>
      <description>Not getting what you want to say.&lt;BR /&gt;&lt;BR /&gt;But here is what I did.&lt;BR /&gt;&lt;BR /&gt;(put your list in a file say an)&lt;BR /&gt;&lt;BR /&gt;Seperate the link with command&lt;BR /&gt;awk -F " " '{print $9}' an&lt;BR /&gt;(this gives listing of links)&lt;BR /&gt;&lt;BR /&gt;Seperate actual files(lat feild in a file an)&lt;BR /&gt;&lt;BR /&gt;awk -F " " '{print $NF}' an&lt;BR /&gt;&lt;BR /&gt;Now I have two lists first is link and second actual list.&lt;BR /&gt;&lt;BR /&gt;Give details what exactly you want.</description>
      <pubDate>Thu, 05 Sep 2002 12:48:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800427#M81774</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2002-09-05T12:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Help with awk script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800428#M81775</link>
      <description>Hi Lisa:&lt;BR /&gt;&lt;BR /&gt;Oops, sorry, I can't count.  That should be:&lt;BR /&gt;&lt;BR /&gt;# awk '{print "rm",$5;print "ln -s",$9,$11}' filein &amp;gt; fileout &lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF..&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Sep 2002 12:49:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800428#M81775</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-09-05T12:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: Help with awk script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800429#M81776</link>
      <description>Good Lord, I mean:&lt;BR /&gt;&lt;BR /&gt;awk '{print "rm",$5;print "ln -s",$11,$9}' filein &amp;gt; fileout&lt;BR /&gt;&lt;BR /&gt;...JRF... &lt;BR /&gt;</description>
      <pubDate>Thu, 05 Sep 2002 12:51:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800429#M81776</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-09-05T12:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help with awk script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800430#M81777</link>
      <description>Lisa,&lt;BR /&gt;&lt;BR /&gt;I just thought of another way to tackle the problem.  You could do another backup using find to just grab the symlinks and cpio to backup the symlinks, and then just overwrite the files on the new system.&lt;BR /&gt;&lt;BR /&gt;find /opt/cs3000 -type l | cpio -ocm &amp;gt;/var/tmp/rcslinks.cpio&lt;BR /&gt;&lt;BR /&gt;Copy the rcslinks.cpio to the new system and:&lt;BR /&gt;&lt;BR /&gt;cpio -ivmcu &lt;BR /&gt;&lt;BR /&gt;Or something like that.  That should overwrite the files with the symlinks.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Sep 2002 12:53:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800430#M81777</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2002-09-05T12:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: Help with awk script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800431#M81778</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;I don't think I can count using the numbers I should :-((&lt;BR /&gt;&lt;BR /&gt;# awk '{print "rm",$9;print "ln -s",$11,$9}'&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 05 Sep 2002 13:01:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800431#M81778</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-09-05T13:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: Help with awk script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800432#M81779</link>
      <description>Thank you Thank you Thank you!!!! I knew I would get GREAT results from you guys - as always! I ended up using John's script - Thank you John - worked like charm and saved me a lot of time trying to figure it out! I would have tried to use the cpio, but there was a week in between (before we noticed the links were gone) where links were being added and or removed so I didn't want to mess anything new up.&lt;BR /&gt;Thanks again!!!</description>
      <pubDate>Thu, 05 Sep 2002 16:26:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800432#M81779</guid>
      <dc:creator>Lisa  Mauer</dc:creator>
      <dc:date>2002-09-05T16:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help with awk script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800433#M81780</link>
      <description>Hi Lisa:&lt;BR /&gt;&lt;BR /&gt;/NO_MORE_POINTS_PLEASE/&lt;BR /&gt;&lt;BR /&gt;I never meant for my bungled typing to receive points -- only the last of my corrections!&lt;BR /&gt;&lt;BR /&gt;The use of the last field (NF) in Andreas Voss' solution is the superior answer.  By using relative field numbers, like:&lt;BR /&gt;&lt;BR /&gt;# awk '{print "rm",$(NF-2)9;print "ln -s",$NF,$(NF-2)}' filein &amp;gt; fileout&lt;BR /&gt;&lt;BR /&gt;...you can handle input created by 'ls -l' or 'ls -ls' where the addition of the '-s' option adds another field and shifts the field containing the filename downstream.&lt;BR /&gt;&lt;BR /&gt;/NO_MORE_POINTS_PLEASE/&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 05 Sep 2002 16:38:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800433#M81780</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-09-05T16:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: Help with awk script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800434#M81781</link>
      <description>Geez, sorry about that James. As you can tell I was in a hurry - but also wanted to be sure I assigned points to everyone who took the time to help me out :) &lt;BR /&gt;Thanks again!</description>
      <pubDate>Thu, 05 Sep 2002 16:59:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-awk-script/m-p/2800434#M81781</guid>
      <dc:creator>Lisa  Mauer</dc:creator>
      <dc:date>2002-09-05T16:59:09Z</dc:date>
    </item>
  </channel>
</rss>

