<?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: how to paser this string in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000714#M96066</link>
    <description>After I read everyone's reply, I dont feel as bad. the Awk command is soo long, but very educational. thank you.&lt;BR /&gt;&lt;BR /&gt;I would like to try the perl command, but, I am still not getting this one quite right, please help me.&lt;BR /&gt;&lt;BR /&gt;the input is&lt;BR /&gt;&lt;BR /&gt;Only in /usr/local/bin: a.config Only in /usr/lib/bin: b.conf Only in /home/smith: c.conf&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Notice there is no "space" before "Only in", but now, I add the file name...how do I include the file name....&lt;BR /&gt;</description>
    <pubDate>Wed, 16 May 2007 12:48:50 GMT</pubDate>
    <dc:creator>Gemini_2</dc:creator>
    <dc:date>2007-05-16T12:48:50Z</dc:date>
    <item>
      <title>how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000710#M96062</link>
      <description>Hi..guru..&lt;BR /&gt;&lt;BR /&gt;I have not script for a while....and need your help again..&lt;BR /&gt;&lt;BR /&gt;say if I have a line like this..&lt;BR /&gt;&lt;BR /&gt;list="Only in /usr/local/bin Only in /usr/lib/bin Only in /home/smith"&lt;BR /&gt;&lt;BR /&gt;I parse that one string into 3 strings such as&lt;BR /&gt;&lt;BR /&gt;Only in /usr/local/bin &lt;BR /&gt;Only in /usr/lib/bin &lt;BR /&gt;Only in /home/smith&lt;BR /&gt;&lt;BR /&gt;I used to know how to do this...&lt;BR /&gt;&lt;BR /&gt;please help out!&lt;BR /&gt;</description>
      <pubDate>Tue, 15 May 2007 18:43:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000710#M96062</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2007-05-15T18:43:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000711#M96063</link>
      <description>Hi Gemini:&lt;BR /&gt;&lt;BR /&gt;# echo ${list} | perl -nle 'print $1 while /(Only in\s+\S+)/g'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 15 May 2007 20:13:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000711#M96063</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-05-15T20:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000712#M96064</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;...and if you want a (longer) 'awk' solution:&lt;BR /&gt;&lt;BR /&gt;# echo ${list} | awk '{while (match($0,/Only in [A-Za-z\/]+/)) {S=substr($0,RSTART,RLENGTH);print S;$0=substr($0,RLENGTH)}}'&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 15 May 2007 20:53:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000712#M96064</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-05-15T20:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000713#M96065</link>
      <description>We can help you, but it would be best if on top of the example (which is a great start!) you could help describe how the string is build.&lt;BR /&gt;&lt;BR /&gt;Speficifcally... Will a new chunk always start with space+"Only in", or just "Only", or...&lt;BR /&gt;&lt;BR /&gt;$ echo $list | perl -pe 's% (Only in)%\n$1%g'&lt;BR /&gt;Only in /usr/local/bin&lt;BR /&gt;Only in /usr/lib/bin&lt;BR /&gt;Only in /home/smith&lt;BR /&gt;&lt;BR /&gt;If it always starts with whatever the first chunk starts with, and there is a space, then you could use:&lt;BR /&gt;&lt;BR /&gt;$ echo $list | perl -pe '$x=substr($_,0,5); s/\s$x/\n$x/g'&lt;BR /&gt;Only in /usr/local/bin&lt;BR /&gt;Only in /usr/lib/bin&lt;BR /&gt;Only in /home/smith&lt;BR /&gt;$&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 15 May 2007 22:04:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000713#M96065</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-05-15T22:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000714#M96066</link>
      <description>After I read everyone's reply, I dont feel as bad. the Awk command is soo long, but very educational. thank you.&lt;BR /&gt;&lt;BR /&gt;I would like to try the perl command, but, I am still not getting this one quite right, please help me.&lt;BR /&gt;&lt;BR /&gt;the input is&lt;BR /&gt;&lt;BR /&gt;Only in /usr/local/bin: a.config Only in /usr/lib/bin: b.conf Only in /home/smith: c.conf&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Notice there is no "space" before "Only in", but now, I add the file name...how do I include the file name....&lt;BR /&gt;</description>
      <pubDate>Wed, 16 May 2007 12:48:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000714#M96066</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2007-05-16T12:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000715#M96067</link>
      <description>Hi (again) Gemini:&lt;BR /&gt;&lt;BR /&gt;OK, given:&lt;BR /&gt;&lt;BR /&gt;# list="Only in /usr/local/bin: a.config Only in /usr/lib/bin: b.conf Only in /home/smit&lt;BR /&gt;h: c.conf"&lt;BR /&gt;&lt;BR /&gt;...then:&lt;BR /&gt;&lt;BR /&gt;# echo ${list} | perl -nle 'print $1 while /(Only in\s+\S+\s\S+)/g'&lt;BR /&gt;&lt;BR /&gt;...yields:&lt;BR /&gt;&lt;BR /&gt;Only in /usr/local/bin: a.config&lt;BR /&gt;Only in /usr/lib/bin: b.conf&lt;BR /&gt;Only in /home/smith: c.conf&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 16 May 2007 12:56:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000715#M96067</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-05-16T12:56:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000716#M96068</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;...and for similar changes to the 'awk':&lt;BR /&gt;&lt;BR /&gt;# echo ${list} | awk '{while (match($0,/Only in ([A-Za-z\/\:]+ [A-Za-z\.]+ *)/)) {S=substr($0,RSTART,RLENGTH);print S;$0=substr($0,RLENGTH)}}'&lt;BR /&gt;&lt;BR /&gt;Note, of course, that with the 'awk' snippet, filenames containing numbers or special characters would fail the match.  I'll leave that as an exercise for you!&lt;BR /&gt;&lt;BR /&gt;The Perl solutions using '\s' for a whitespace and '\S' for a nonwhitespace is easier (as Perl is!).  For that matter, Hein's solutions are quite elegant too, and required no changes.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 16 May 2007 13:36:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000716#M96068</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-05-16T13:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000717#M96069</link>
      <description>Yet another (shorter) awk solution :)&lt;BR /&gt;&lt;BR /&gt;# echo $list | awk -F"Only" '{for(i=1;i&amp;lt;=NF;++i) if($i) print FS$i}'&lt;BR /&gt;&lt;BR /&gt;~cheers</description>
      <pubDate>Wed, 16 May 2007 14:36:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000717#M96069</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-05-16T14:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000718#M96070</link>
      <description>Hi Sandman:&lt;BR /&gt;&lt;BR /&gt;That's a VERY elegant 'awk' solution!  Shorter AND sensitive only to matching the keyword "Only".  I always learn better ways with 'awk' and 'sed' reading your contributions.  &lt;BR /&gt;&lt;BR /&gt;/* NO POINTS for this post, please */&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 16 May 2007 14:45:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000718#M96070</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-05-16T14:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000719#M96071</link>
      <description>That coming from the master (JRF) himself is quite the compliment.&lt;BR /&gt;&lt;BR /&gt;:D</description>
      <pubDate>Wed, 16 May 2007 14:57:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000719#M96071</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-05-16T14:57:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000720#M96072</link>
      <description>Actually, I parse the string because I want to do the following.&lt;BR /&gt;&lt;BR /&gt;I want to diff two directories, and only display the "Only In" result.&lt;BR /&gt;&lt;BR /&gt;Is there an option in the diff that can do that? so, I dont even have to parse the result.&lt;BR /&gt;&lt;BR /&gt;Mimosa</description>
      <pubDate>Wed, 16 May 2007 15:43:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000720#M96072</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2007-05-16T15:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000721#M96073</link>
      <description>Hi (again) Gemini:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; I want to diff two directories, and only display the "Only In" result&lt;BR /&gt;&lt;BR /&gt;See the manpages for 'dircmp' :&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://docs.hp.com/en/B2355-60105/dircmp.1.html" target="_blank"&gt;http://docs.hp.com/en/B2355-60105/dircmp.1.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 16 May 2007 16:07:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000721#M96073</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-05-16T16:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000722#M96074</link>
      <description>Not sure I understand...could you post the diff(1) command you are using?</description>
      <pubDate>Wed, 16 May 2007 16:07:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000722#M96074</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-05-16T16:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000723#M96075</link>
      <description>It would have really helped had you asked the real question rather than leading everyone of a Wild Goose chase. I think Hein alluded to this earlier. Anyway, you can leverage the comm command suppressing the entries found in both directories.&lt;BR /&gt;&lt;BR /&gt;Something like this:&lt;BR /&gt;---------------------------------------&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;typeset TDIR=${TMPDIR:-/var/tmp}&lt;BR /&gt;typeset PROG=${0##*/}&lt;BR /&gt;typeset T1=${TDIR}/X${$}_1.tmp&lt;BR /&gt;typeset T2=${TDIR}/X${$}_2.tmp&lt;BR /&gt;&lt;BR /&gt;trap 'eval rm -f ${T1} ${T2}' 0 1 2 15&lt;BR /&gt;&lt;BR /&gt;typeset -i STAT=0&lt;BR /&gt;&lt;BR /&gt;if [[ ${#} -ge 2 ]]&lt;BR /&gt;  then&lt;BR /&gt;    typeset D1=${1}&lt;BR /&gt;    typeset D2=${2}&lt;BR /&gt;    shift 2&lt;BR /&gt;    if [[ -d "${D1}" &amp;amp;&amp;amp; -d "${D2}" ]]&lt;BR /&gt;      then&lt;BR /&gt;        ls D1 | sort &amp;gt; ${T1}&lt;BR /&gt;        ls D2 | sort &amp;gt; ${T2}&lt;BR /&gt;        comm -3 ${T1} ${T2}&lt;BR /&gt;        STAT=${?}&lt;BR /&gt;      else&lt;BR /&gt;        echo "${PROG}: ${D1} and/or ${D2} not found and/or not directories." &amp;gt;&amp;amp;2&lt;BR /&gt;        STAT=254&lt;BR /&gt;      fi&lt;BR /&gt;  else&lt;BR /&gt;    echo "Usage: ${PROG} dir1 dir2" &amp;gt;&amp;amp;2&lt;BR /&gt;    STAT=255&lt;BR /&gt;  fi&lt;BR /&gt;exit ${STAT}&lt;BR /&gt;-----------------------------------------&lt;BR /&gt;&lt;BR /&gt;If I didn't make no typing booboo's; that should work. Use it like "dirdiff.sh dir1 dir2". Files that are unique to dir1 appear in column1 of stdout and files unique to dir2 appear in column2.&lt;BR /&gt;&lt;BR /&gt;Man comm for details. You could easily separate this into 3 output files but that is left for you.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 16 May 2007 16:19:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000723#M96075</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-05-16T16:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000724#M96076</link>
      <description>Ooops, I'm stupid I did have a minor error, D1 rather than ${D1}.&lt;BR /&gt;----------------------------------------&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;typeset TDIR=${TMPDIR:-/var/tmp}&lt;BR /&gt;typeset PROG=${0##*/}&lt;BR /&gt;typeset T1=${TDIR}/X${$}_1.tmp&lt;BR /&gt;typeset T2=${TDIR}/X${$}_2.tmp&lt;BR /&gt;&lt;BR /&gt;trap 'eval rm -f ${T1} ${T2}' 0 1 2 15&lt;BR /&gt;&lt;BR /&gt;typeset -i STAT=0&lt;BR /&gt;&lt;BR /&gt;if [[ ${#} -ge 2 ]]&lt;BR /&gt;  then&lt;BR /&gt;    typeset D1=${1}&lt;BR /&gt;    typeset D2=${2}&lt;BR /&gt;    shift 2&lt;BR /&gt;    if [[ -d "${D1}" &amp;amp;&amp;amp; -d "${D2}" ]]&lt;BR /&gt;      then&lt;BR /&gt;        ls ${D1} | sort &amp;gt; ${T1}&lt;BR /&gt;        ls ${D2} | sort &amp;gt; ${T2}&lt;BR /&gt;        comm -3 ${T1} ${T2}&lt;BR /&gt;        STAT=${?}&lt;BR /&gt;      else&lt;BR /&gt;        echo "${PROG}: ${D1} and/or ${D2} not found and/or not directories." &amp;gt;&amp;amp;2&lt;BR /&gt;        STAT=254&lt;BR /&gt;      fi&lt;BR /&gt;  else&lt;BR /&gt;    echo "Usage: ${PROG} dir1 dir2" &amp;gt;&amp;amp;2&lt;BR /&gt;    STAT=255&lt;BR /&gt;  fi&lt;BR /&gt;exit ${STAT}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;-----------------------------------------&lt;BR /&gt;&lt;BR /&gt;Dircmp may be too intensive for you because it not only does file names but also compares the files themselves.</description>
      <pubDate>Wed, 16 May 2007 16:23:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000724#M96076</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-05-16T16:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000725#M96077</link>
      <description>No....I dont want to waste everyone's time.&lt;BR /&gt;&lt;BR /&gt;I want to learn different ways to parse the strings anyway. I read every post and try to understand it.&lt;BR /&gt;&lt;BR /&gt;you guys are being extremely helpful.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;really appreciate.</description>
      <pubDate>Wed, 16 May 2007 17:04:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000725#M96077</guid>
      <dc:creator>Gemini_2</dc:creator>
      <dc:date>2007-05-16T17:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000726#M96078</link>
      <description>Imho if the diff(1) you are using is constructed as shown...&lt;BR /&gt;&lt;BR /&gt;# VAR=$(diff /dir1/dir2 /dir1/dir3)&lt;BR /&gt;&lt;BR /&gt;then echo'ing the doubly-quoted VAR will do the trick w/o any scripting...&lt;BR /&gt;&lt;BR /&gt;# echo "$VAR"&lt;BR /&gt;&lt;BR /&gt;~hope it helps</description>
      <pubDate>Wed, 16 May 2007 17:32:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000726#M96078</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2007-05-16T17:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to paser this string</title>
      <link>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000727#M96079</link>
      <description>Hi,&lt;BR /&gt;why not the old good Unix command diff?&lt;BR /&gt;&lt;BR /&gt;/&amp;gt; ls -1 t1&lt;BR /&gt;a&lt;BR /&gt;b&lt;BR /&gt;&lt;BR /&gt;/&amp;gt;ls -1 t2&lt;BR /&gt;b&lt;BR /&gt;c&lt;BR /&gt;&lt;BR /&gt;/&amp;gt; diff t1 t2&lt;BR /&gt;Only in t1: a&lt;BR /&gt;Only in t2: c&lt;BR /&gt;&lt;BR /&gt;It shows only the file that are not in both dirs.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;Art</description>
      <pubDate>Thu, 17 May 2007 03:32:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/how-to-paser-this-string/m-p/4000727#M96079</guid>
      <dc:creator>Arturo Galbiati</dc:creator>
      <dc:date>2007-05-17T03:32:33Z</dc:date>
    </item>
  </channel>
</rss>

