<?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: regular expressions in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503735#M62016</link>
    <description>Hi Maxim:&lt;BR /&gt;&lt;BR /&gt;# perl -ple 's/(^\s*kernel(?!.*notsc))(.*$)/$1$2\ xxxxx/' grub.conf&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Sat, 26 Sep 2009 23:10:01 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2009-09-26T23:10:01Z</dc:date>
    <item>
      <title>regular expressions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503731#M62012</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Can somebody help me with a sed and regular expressions?&lt;BR /&gt;I need a script that will append 'notsc' to every line in a file that starts with 'kernel' but does not contain 'notsc'.&lt;BR /&gt;I tried the following but it doesn't work:&lt;BR /&gt;sed -i '/^[[:space:]]*kernel(?!notsc)/s|$| notsc|' grub.conf&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Maxim.</description>
      <pubDate>Sat, 26 Sep 2009 10:14:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503731#M62012</guid>
      <dc:creator>M. Rozin</dc:creator>
      <dc:date>2009-09-26T10:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503732#M62013</link>
      <description>You can use this method:&lt;BR /&gt;First use grep to find out 'kernel' without 'notsc' ;&lt;BR /&gt;&lt;BR /&gt;cat grub.conf | grep -v notsc | grep ^kernel &amp;gt; temp1&lt;BR /&gt;&lt;BR /&gt;sed -e 's/\^kernel/\$notsc/' grub.conf&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 26 Sep 2009 19:41:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503732#M62013</guid>
      <dc:creator>Hakki Aydin Ucar</dc:creator>
      <dc:date>2009-09-26T19:41:54Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503733#M62014</link>
      <description>sorry,&lt;BR /&gt;&lt;BR /&gt;sed -e 's/\^kernel/\$notsc/g' temp1 &amp;gt; temp2&lt;BR /&gt;&lt;BR /&gt;if it is OK &lt;BR /&gt;&lt;BR /&gt;cat temp2 &amp;gt; grub.conf</description>
      <pubDate>Sat, 26 Sep 2009 19:43:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503733#M62014</guid>
      <dc:creator>Hakki Aydin Ucar</dc:creator>
      <dc:date>2009-09-26T19:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503734#M62015</link>
      <description>Maybe a this command line&lt;BR /&gt;&lt;BR /&gt;sed  -i '/kernel.*notsc/ !{s/^[[:space:]]*kernel.*/&amp;amp; notsc/}' grub.conf&lt;BR /&gt;&lt;BR /&gt;can do the job.</description>
      <pubDate>Sat, 26 Sep 2009 20:38:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503734#M62015</guid>
      <dc:creator>H.Becker</dc:creator>
      <dc:date>2009-09-26T20:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503735#M62016</link>
      <description>Hi Maxim:&lt;BR /&gt;&lt;BR /&gt;# perl -ple 's/(^\s*kernel(?!.*notsc))(.*$)/$1$2\ xxxxx/' grub.conf&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sat, 26 Sep 2009 23:10:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503735#M62016</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-09-26T23:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503736#M62017</link>
      <description>First of all, thank you for your reply guys!&lt;BR /&gt;&lt;BR /&gt;Hakki - I think that your suggestion will leave only the kernel lines in grub.conf, while I want to leave the file as is, and just to append 'notsc' to some of the lines.&lt;BR /&gt;&lt;BR /&gt;H - I will try you command at work and will let you know whether it works.&lt;BR /&gt;&lt;BR /&gt;James - I asked for a sed command because this script should run on newly installed systems and I am not 100% sure that perl is part of the default installation. But anyway, I will try it at work and will let you know.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Maxim.</description>
      <pubDate>Sun, 27 Sep 2009 00:22:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503736#M62017</guid>
      <dc:creator>M. Rozin</dc:creator>
      <dc:date>2009-09-27T00:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503737#M62018</link>
      <description>Hi (again) Maxim:&lt;BR /&gt;&lt;BR /&gt;# perl -ple 's/(^\s*kernel(?!.*notsc))(.*$)/$1$2\ xxxxx/' grub.conf&lt;BR /&gt;&lt;BR /&gt;...should have been:&lt;BR /&gt;&lt;BR /&gt;# perl -ple 's/(^\s*kernel(?!.*notsc))(.*$)/$1$2\ notsc/' grub.conf&lt;BR /&gt;&lt;BR /&gt;The 'xxxxx' was what I used for testing as it simplified spotting good and bad cases.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; "I am not 100% sure that perl is part of the default installation."&lt;BR /&gt;&lt;BR /&gt;Interesting point.  If I recall correctly, Perl is part of Debian, Ubuntu, OpenSUSE and definitely Fedora.  I'd be very interested to know your findings.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 27 Sep 2009 13:49:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503737#M62018</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-09-27T13:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503738#M62019</link>
      <description>Thank you James for correcting the mistake. I was wondering about the purpose of xxxx :)&lt;BR /&gt;&lt;BR /&gt;In our case it's RHEL, but we have a customized installation, so I have to check whether perl is part of this installation.&lt;BR /&gt;&lt;BR /&gt;I will check it on Tuesday, when I'll be in the office and will let you know.&lt;BR /&gt;&lt;BR /&gt;Maxim.</description>
      <pubDate>Sun, 27 Sep 2009 14:17:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503738#M62019</guid>
      <dc:creator>M. Rozin</dc:creator>
      <dc:date>2009-09-27T14:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503739#M62020</link>
      <description>Hello M.Rozin!&lt;BR /&gt;&lt;BR /&gt;Here a simple sed script to accomplish this task:&lt;BR /&gt;&lt;BR /&gt;sed -n -e '/notsc/{&lt;BR /&gt;p&lt;BR /&gt;d&lt;BR /&gt;}' -e '/^kernel/s/$/notsc/' -e 'p'&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;&lt;BR /&gt;Kobylka</description>
      <pubDate>Mon, 28 Sep 2009 06:49:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503739#M62020</guid>
      <dc:creator>kobylka</dc:creator>
      <dc:date>2009-09-28T06:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503740#M62021</link>
      <description>Actually I made a script it was working in shell command by command, but inside sed operator string goes to split ?? it needs to keep strict line to work exactly, &lt;BR /&gt;-May be somebody will come up a solution to make working a string inside a sed ??&lt;BR /&gt;test it you will see the problem :&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;cat testfile &amp;gt; test2file&lt;BR /&gt;line2=" notsc"&lt;BR /&gt;cat test2file |grep -i kernel |grep -v notsc | while read line&lt;BR /&gt; do&lt;BR /&gt; sed "s/$line/$line $line2/" test2file &amp;gt; test3file&lt;BR /&gt; cp test3file test2file&lt;BR /&gt; done&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 28 Sep 2009 11:35:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503740#M62021</guid>
      <dc:creator>Hakki Aydin Ucar</dc:creator>
      <dc:date>2009-09-28T11:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503741#M62022</link>
      <description>Thank you everybody for all the suggestions.&lt;BR /&gt;&lt;BR /&gt;Hakki - you script might do the job, but I am looking for a more "elegant" solution. Thank you for the effort anyway.&lt;BR /&gt;&lt;BR /&gt;Kobylka - your script doesn't seem to work.&lt;BR /&gt;&lt;BR /&gt;James - your perl suggestion does the job, but it prints the contents to standard output rather than replacing the actual file. It's probably easy to change it to replace the file, but I am not a big perl expert. BTW, our default RHEL installation does include perl.&lt;BR /&gt;&lt;BR /&gt;And the winner is H.Becker. This is exactly what I need. Here is the exact command that I am going to use:&lt;BR /&gt;sed -i '/^[[:space:]]*kernel.*notsc.*/ !{s/^[[:space:]]*kernel.*/&amp;amp; notsc/}' grub.conf&lt;BR /&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Maxim.</description>
      <pubDate>Wed, 30 Sep 2009 05:06:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503741#M62022</guid>
      <dc:creator>M. Rozin</dc:creator>
      <dc:date>2009-09-30T05:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503742#M62023</link>
      <description>Hi Maxim:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; James - your perl suggestion does the job, but it prints the contents to standard output rather than replacing the actual file&lt;BR /&gt;&lt;BR /&gt;That's easy to make happen.  We simply add the '-i' switch to enable in-place editing and optionally an argument with it to use as a suffix for a backup copy of the unmodified file.  In all:&lt;BR /&gt;&lt;BR /&gt;# perl -ple 's/(^\s*kernel(?!.*notsc))(.*$)/$1$2\ notsc/' grub.conf&lt;BR /&gt;&lt;BR /&gt;...becomes:&lt;BR /&gt;&lt;BR /&gt;# perl -pi.old -e 's/(^\s*kernel(?!.*notsc))(.*$)/$1$2\ notsc/' grub.conf&lt;BR /&gt;&lt;BR /&gt;The 'grub.conf' will be modified in situ while the unmodified file will be present as 'grub.conf.old'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Wed, 30 Sep 2009 10:49:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503742#M62023</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-09-30T10:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503743#M62024</link>
      <description>Thanks for the update James</description>
      <pubDate>Wed, 30 Sep 2009 12:27:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503743#M62024</guid>
      <dc:creator>M. Rozin</dc:creator>
      <dc:date>2009-09-30T12:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: regular expressions</title>
      <link>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503744#M62025</link>
      <description>&amp;gt;Kobylka - your script doesn't seem to work.&lt;BR /&gt;&lt;BR /&gt;It seems to work fine for me.  If you provide a file, it writes the output to stdout.  Though -i option doesn't work with -n.</description>
      <pubDate>Tue, 17 Nov 2009 06:20:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/regular-expressions/m-p/4503744#M62025</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-11-17T06:20:14Z</dc:date>
    </item>
  </channel>
</rss>

