<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
  <title>Linux Format forums</title>
  <link>http://linuxformat.com/forums/index.php</link>
  <description>Help, discussion, magazine feedback and more</description>
  <language>english</language>
  <copyright>(c) Copyright Fri May 24, 2013 3:47 am by Linux Format forums</copyright>
  <managingEditor>webmaster@linuxformat.com</managingEditor>
  <webMaster>webmaster@linuxformat.com</webMaster>
  <pubDate>Fri May 24, 2013 3:47 am</pubDate>
  <lastBuildDate>Fri May 24, 2013 3:47 am</lastBuildDate>
  <docs>http://backend.userland.com/rss</docs>
  <generator>phpBB2 RSS Syndication Mod by Lucas</generator>
  <ttl>1</ttl>

  <image>
    <title>Linux Format forums</title>
    <url></url>
    <link>http://linuxformat.com/forums/</link>
    <description>Help, discussion, magazine feedback and more</description>
  </image>

                                      <item>
                                        <title>Re: Edit a file via shell script</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=22572#22572</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=31'&gt;crispibits&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Wed May 03, 2006 1:18 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      For this you'd use awk:&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;awk '/^1 / &amp;#123;$3 = &amp;quot;999&amp;quot;&amp;#125; &amp;#123;print $0&amp;#125;' testfile&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
This means 'if the line starts with 1 followed by a space, set the third field to be 999.  Regardless of what came before, print the whole line.&lt;br /&gt;
Awk assumes the field separator to be a space, but you can alter that using the -F flag.</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=22572#22572</comments>
                                        <author>crispibits</author>
                                        <pubDate>Wed May 03, 2006 1:18 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=22572#22572</guid>
                                      </item>
                                      <item>
                                        <title>Re: Edit a file via shell script</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=22561#22561</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=6851'&gt;SSL&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Wed May 03, 2006 11:08 am&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Hi,&lt;br /&gt;
&lt;br /&gt;
Thanks for that... I now have it working as well as other options but i'm now stuck on the final part...&lt;br /&gt;
&lt;br /&gt;
I'm using sed to replace the phone number in a file.e.g.&lt;br /&gt;
&lt;br /&gt;
./script 1 2222 999 (This would replace the phone number for ID 2222 to 999)? I can get it to work if i specify the new and old number in the syntax when i run the script but not when i use just the ID and new number?&lt;br /&gt;
&lt;br /&gt;
Is there a command to replace just the third word?&lt;br /&gt;
&lt;br /&gt;
Any ideas?&lt;br /&gt;
&lt;br /&gt;
James.</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=22561#22561</comments>
                                        <author>SSL</author>
                                        <pubDate>Wed May 03, 2006 11:08 am</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=22561#22561</guid>
                                      </item>
                                      <item>
                                        <title>RE: Edit a file via shell script</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=22201#22201</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=31'&gt;crispibits&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Thu Apr 27, 2006 7:45 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      I don't want to ruin the joy of working out the whole script, but the following will delete a line where it contains 222.  See if this makes sense, and take it from there...&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;sed -e '/222/d' textfile&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=22201#22201</comments>
                                        <author>crispibits</author>
                                        <pubDate>Thu Apr 27, 2006 7:45 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=22201#22201</guid>
                                      </item>
                                      <item>
                                        <title>Edit a file via shell script</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=22185#22185</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=6851'&gt;SSL&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Thu Apr 27, 2006 4:12 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      I'm trying to edit a file via a shell script... I have 1 script and one file. The text file is made up of 5 lines e.g.&lt;br /&gt;
james 1111 98987678&lt;br /&gt;
John 2222 848474838&lt;br /&gt;
&lt;br /&gt;
the 1111 and 2222 are ID's.&lt;br /&gt;
I want to run my script and delete the line with the ID i specify. e.g.&lt;br /&gt;
./script textfile -d 2222 - this will delete line with id 2222?&lt;br /&gt;
&lt;br /&gt;
How do i do this?</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=22185#22185</comments>
                                        <author>SSL</author>
                                        <pubDate>Thu Apr 27, 2006 4:12 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=22185#22185</guid>
                                      </item></channel></rss>