<?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 Wed Jun 19, 2013 2:17 am by Linux Format forums</copyright>
  <managingEditor>webmaster@linuxformat.com</managingEditor>
  <webMaster>webmaster@linuxformat.com</webMaster>
  <pubDate>Wed Jun 19, 2013 2:17 am</pubDate>
  <lastBuildDate>Wed Jun 19, 2013 2:17 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: Re: RE: editing text files from within the shell</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=17305#17305</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=133'&gt;jjmac&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Sun Feb 12, 2006 2:20 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      alloydog wrote:&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&lt;br /&gt;
You mean:&lt;br /&gt;
&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In a nut shell &lt;img src=&quot;images/smiles/icon_smile.gif&quot; alt=&quot;Smile&quot; border=&quot;0&quot; /&gt; (hehehe) (um ,,, that is a jpg you know !  &lt;img src=&quot;images/smiles/icon_rolleyes.gif&quot; alt=&quot;Rolling Eyes&quot; border=&quot;0&quot; /&gt; )&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
snuffsaid:&lt;br /&gt;
&amp;gt;&amp;gt;&lt;br /&gt;
I was staring at the man page and even the &quot;classic shell scripting&quot; book late at night but just could not see for looking,&lt;br /&gt;
&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tell me about it (grin), mind you, some of the google feed back on sed is worth the squize &lt;img src=&quot;images/smiles/icon_wink.gif&quot; alt=&quot;Wink&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
jm</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=17305#17305</comments>
                                        <author>jjmac</author>
                                        <pubDate>Sun Feb 12, 2006 2:20 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=17305#17305</guid>
                                      </item>
                                      <item>
                                        <title>RE: Re: RE: editing text files from within the shell</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=17164#17164</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=6005'&gt;snuffsaid&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Thu Feb 09, 2006 2:36 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      a big thank you to you all. I was staring at the man page and even the &quot;classic shell scripting&quot; book late at night but just could not see for looking, as they say. &lt;br /&gt;
&lt;br /&gt;
Cheers&lt;br /&gt;
&lt;br /&gt;
Pete</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=17164#17164</comments>
                                        <author>snuffsaid</author>
                                        <pubDate>Thu Feb 09, 2006 2:36 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=17164#17164</guid>
                                      </item>
                                      <item>
                                        <title>Re: RE: editing text files from within the shell</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=17159#17159</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=127'&gt;alloydog&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Thu Feb 09, 2006 1:03 pm&lt;br /&gt;&lt;br /&gt;
                                      &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;jjmac wrote:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;quote&quot;&gt;&lt;img src=&quot;images/smiles/icon_rolleyes.gif&quot; alt=&quot;Rolling Eyes&quot; border=&quot;0&quot; /&gt; , wish i had looked at the info page at the time (good_grief.png) &lt;img src=&quot;images/smiles/icon_rolleyes.gif&quot; alt=&quot;Rolling Eyes&quot; border=&quot;0&quot; /&gt;&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
You mean:&lt;br /&gt;
&lt;br /&gt;
&lt;img src=&quot;http://www.mrgilfeather.com/mediac/400_0/media/Good~Grief.jpg&quot; border=&quot;0&quot; /&gt;</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=17159#17159</comments>
                                        <author>alloydog</author>
                                        <pubDate>Thu Feb 09, 2006 1:03 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=17159#17159</guid>
                                      </item>
                                      <item>
                                        <title>RE: editing text files from within the shell</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=17153#17153</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=133'&gt;jjmac&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Thu Feb 09, 2006 8:52 am&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      &lt;img src=&quot;images/smiles/icon_rolleyes.gif&quot; alt=&quot;Rolling Eyes&quot; border=&quot;0&quot; /&gt; , wish i had looked at the info page at the time (good_grief.png) &lt;img src=&quot;images/smiles/icon_rolleyes.gif&quot; alt=&quot;Rolling Eyes&quot; border=&quot;0&quot; /&gt;</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=17153#17153</comments>
                                        <author>jjmac</author>
                                        <pubDate>Thu Feb 09, 2006 8:52 am</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=17153#17153</guid>
                                      </item>
                                      <item>
                                        <title>RE: editing text files from within the shell</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=17105#17105</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=5'&gt;nelz&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Wed Feb 08, 2006 9:33 am&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      The sed manpage is limited, but the last paragraph tells you all you need to know, full documentation is in the info page.&lt;br /&gt;
&lt;br /&gt;
You can do what you want with&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;&lt;br /&gt;
#add&lt;br /&gt;
echo &amp;quot;$&amp;#123;NAME&amp;#125;&amp;#58;$&amp;#123;LIMIT&amp;#125;&amp;quot; &amp;gt;&amp;gt;configfile&lt;br /&gt;
#remove &lt;br /&gt;
sed -i &amp;quot;/^$&amp;#123;NAME&amp;#125;&amp;#58;/d&amp;quot; configfile&lt;br /&gt;
#modify&lt;br /&gt;
sed -i &amp;quot;s/^$&amp;#123;NAME&amp;#125;&amp;#58;.*/$&amp;#123;NAME&amp;#125;&amp;#58;$&amp;#123;LIMIT&amp;#125;/&amp;quot; configfile&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
You'll have to add the usual checks, like making sure you don't add a user twice or try to modify a non-existent user.</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=17105#17105</comments>
                                        <author>nelz</author>
                                        <pubDate>Wed Feb 08, 2006 9:33 am</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=17105#17105</guid>
                                      </item>
                                      <item>
                                        <title>RE: editing text files from within the shell</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=17100#17100</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=133'&gt;jjmac&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Wed Feb 08, 2006 8:21 am&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Information isn't waffle &lt;img src=&quot;images/smiles/icon_smile.gif&quot; alt=&quot;Smile&quot; border=&quot;0&quot; /&gt;.&lt;br /&gt;
&lt;br /&gt;
Sounds like a job for &quot;sed&quot; though. A google on sed will come up with lots of diverse sources of information. Including histories, &quot;examples&quot; etc. Unfortuately the man page is quite lacking. I think that because sed has been around for such a long time, it isn't really centralised to the dgree where a single site will provide all the required documentation. So, as a result, it is scattered. Certainly, imo,  one of the great unix tools.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
jm</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=17100#17100</comments>
                                        <author>jjmac</author>
                                        <pubDate>Wed Feb 08, 2006 8:21 am</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=17100#17100</guid>
                                      </item>
                                      <item>
                                        <title>RE: editing text files from within the shell</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=17036#17036</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=6005'&gt;snuffsaid&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Tue Feb 07, 2006 9:43 am&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Sorry for not providing more info, I didn't want to waffle on too much. I have a thrid party application that limits the amount of logins using the application, but does not limit the number of times a user can log in. I have found a way of limiting the users to be only able to login a certain number of times by editing the apps startup script to refer to another file to see how many times that user is allowed to log in. Now I am trying to create a script that can be run from the command line so the person in charge doesn't have to use vi. All he would need to do is &amp;lt;command&amp;gt; -a (add), -r (remove) -m(modify) and so on. This would edit the file, whichis only about 20 lines long and is set out like &quot;username:number of logins&quot;. The : can be replaced by anything really.&lt;br /&gt;
Hope I haven't waffled on too much and it's made things a little clearer&lt;br /&gt;
In the mean time I'll go and try the -i option&lt;br /&gt;
Many Thanks&lt;br /&gt;
&lt;br /&gt;
Pete</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=17036#17036</comments>
                                        <author>snuffsaid</author>
                                        <pubDate>Tue Feb 07, 2006 9:43 am</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=17036#17036</guid>
                                      </item>
                                      <item>
                                        <title>RE: editing text files from within the shell</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=17025#17025</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=5'&gt;nelz&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Tue Feb 07, 2006 12:46 am&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      If using sed, the s command only replaces content within a line, you need d to delete a complete line or block of lines.&lt;br /&gt;
&lt;br /&gt;
Also, use the -i option to modify a file in place instead of sending pout put to a temporary file, deleting and renaming.&lt;br /&gt;
&lt;br /&gt;
As &lt;span style=&quot;font-weight: bold&quot;&gt;Nigel&lt;/span&gt; says, a clearer idea of what you are doing will result in a clearer recommendation.</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=17025#17025</comments>
                                        <author>nelz</author>
                                        <pubDate>Tue Feb 07, 2006 12:46 am</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=17025#17025</guid>
                                      </item>
                                      <item>
                                        <title>RE: editing text files from within the shell</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=17019#17019</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=162'&gt;Nigel&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Mon Feb 06, 2006 11:53 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      What exactly are you trying to do to the file ? There's a good chance that both sed and awk can do what you want, but one may be easier than the other for the task you have in mind.</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=17019#17019</comments>
                                        <author>Nigel</author>
                                        <pubDate>Mon Feb 06, 2006 11:53 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=17019#17019</guid>
                                      </item>
                                      <item>
                                        <title>editing text files from within the shell</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=17013#17013</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=6005'&gt;snuffsaid&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Mon Feb 06, 2006 10:48 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      evening all,&lt;br /&gt;
&lt;br /&gt;
I have been trying to get a shell script working that will automatically edit a text file. The text file is set out using ':' as a delimiter between bits of info, a bit like the /etc/passwd file. I am trying to use only bash shell scripting for this, no PHP, Ruby, PERL, etc. for reasons of portability, not all the machines have such goodies.&lt;br /&gt;
I have managed to get the script to edit a line by using the output of sed and redirecting it to a new file, then copying the file back over the original. Though this seems to leave a blank line in place of the old line if I remove the files entry with the script, though editing the second field does work.&lt;br /&gt;
Does anyone know of a more elegant way of doing this? If not with sed then I think all of my machines do have awk if that is of any help to someone.&lt;br /&gt;
&lt;br /&gt;
Cheers&lt;br /&gt;
&lt;br /&gt;
Pete</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=17013#17013</comments>
                                        <author>snuffsaid</author>
                                        <pubDate>Mon Feb 06, 2006 10:48 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=17013#17013</guid>
                                      </item></channel></rss>