<?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: Sed  to remove comma in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854845#M94466</link>
    <description>I have a couple of sed ways:&lt;BR /&gt;&lt;BR /&gt;sed "s/^\(.*\)\:\:\(.*\)\:.*$/\1::\2:/"&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;sed "s/^\(.*\)\(\:.*$\)/\1:/"&lt;BR /&gt;&lt;BR /&gt;both produce&lt;BR /&gt;&lt;BR /&gt;# export OLINE="Group1::101:user1,users,user3,user4,user4"&lt;BR /&gt;# echo $OLINE | sed "s/^\(.*\)\(\:.*$\)/\1:/"&lt;BR /&gt;Group1::101:&lt;BR /&gt;# echo $OLINE | sed "s/^\(.*\)\:\:\(.*\)\:.*$/\1::\2:/"&lt;BR /&gt;Group1::101:&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
    <pubDate>Sun, 01 Dec 2002 03:52:24 GMT</pubDate>
    <dc:creator>harry d brown jr</dc:creator>
    <dc:date>2002-12-01T03:52:24Z</dc:date>
    <item>
      <title>Sed  to remove comma</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854839#M94460</link>
      <description>How do I sed&lt;BR /&gt;&lt;BR /&gt;Group1::101:user1,users,user3,user4,user4&lt;BR /&gt;to&lt;BR /&gt;Group::101:&lt;BR /&gt;&lt;BR /&gt;The following command&lt;BR /&gt;sed -e 's/'$username'//' -e '/,$//' /etc/group&lt;BR /&gt;not working&lt;BR /&gt;&lt;BR /&gt;Here's the output&lt;BR /&gt;Group1:::101:,,,,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Aravind</description>
      <pubDate>Sat, 30 Nov 2002 09:02:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854839#M94460</guid>
      <dc:creator>Aravind_3</dc:creator>
      <dc:date>2002-11-30T09:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: Sed  to remove comma</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854840#M94461</link>
      <description>&lt;BR /&gt;cat /etc/group|sed 's/:/ /g'|sed 's/,/ /g'|awk '{print $1"::"$2":"}'&lt;BR /&gt;</description>
      <pubDate>Sat, 30 Nov 2002 09:57:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854840#M94461</guid>
      <dc:creator>Stefan Farrelly</dc:creator>
      <dc:date>2002-11-30T09:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Sed  to remove comma</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854841#M94462</link>
      <description>grep [,:]$username /etc/group | cut -d: -f1,3</description>
      <pubDate>Sat, 30 Nov 2002 12:56:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854841#M94462</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-11-30T12:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: Sed  to remove comma</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854842#M94463</link>
      <description>how about:&lt;BR /&gt;sed 's/\(.*:\).*/\1/'/etc/group</description>
      <pubDate>Sat, 30 Nov 2002 15:03:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854842#M94463</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2002-11-30T15:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Sed  to remove comma</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854843#M94464</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;First, presuming you mean to delete one command from the end of the line, it appears your second expression should be:&lt;BR /&gt;-e 's/,$//'&lt;BR /&gt;&lt;BR /&gt;I assume you are executing this in a loop and passing a different value for $username each time.  If so, you have 4 possible cases (assume $username = user1):&lt;BR /&gt;1) $username is the only user in the group&lt;BR /&gt;Group1:::101:user1&lt;BR /&gt;2) $username is the first of several users in the group&lt;BR /&gt;Group1:::101:user1,user2,user3&lt;BR /&gt;3) $username is the last of several users in the group&lt;BR /&gt;Group1:::101:user3,user2,user1&lt;BR /&gt;4) $username is neither first nor last of several users in the group&lt;BR /&gt;Group1:::101:user2,user1,user3&lt;BR /&gt;&lt;BR /&gt;Your sed statement needs to allow for each possibility.  One method would be:&lt;BR /&gt;sed -e 's/'$username'//' -e 's/:,/:/' -e 's/,$//' -e 's/,,/,/' /etc/group&lt;BR /&gt;&lt;BR /&gt;Darrell</description>
      <pubDate>Sat, 30 Nov 2002 16:18:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854843#M94464</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2002-11-30T16:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: Sed  to remove comma</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854844#M94465</link>
      <description>I've a typo in my first sentence.  It should read "delete one comma" instead of "delete one command".&lt;BR /&gt;&lt;BR /&gt;Darrell</description>
      <pubDate>Sat, 30 Nov 2002 16:20:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854844#M94465</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2002-11-30T16:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: Sed  to remove comma</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854845#M94466</link>
      <description>I have a couple of sed ways:&lt;BR /&gt;&lt;BR /&gt;sed "s/^\(.*\)\:\:\(.*\)\:.*$/\1::\2:/"&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;sed "s/^\(.*\)\(\:.*$\)/\1:/"&lt;BR /&gt;&lt;BR /&gt;both produce&lt;BR /&gt;&lt;BR /&gt;# export OLINE="Group1::101:user1,users,user3,user4,user4"&lt;BR /&gt;# echo $OLINE | sed "s/^\(.*\)\(\:.*$\)/\1:/"&lt;BR /&gt;Group1::101:&lt;BR /&gt;# echo $OLINE | sed "s/^\(.*\)\:\:\(.*\)\:.*$/\1::\2:/"&lt;BR /&gt;Group1::101:&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Sun, 01 Dec 2002 03:52:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854845#M94466</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-12-01T03:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: Sed  to remove comma</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854846#M94467</link>
      <description>Errr...&lt;BR /&gt;&lt;BR /&gt;have you tried putting the comma after the username you want to remove?&lt;BR /&gt;&lt;BR /&gt;sed -e 's/'$username'[,]*//' /etc/group &lt;BR /&gt;&lt;BR /&gt;should remove the comma if it exists, and work when there is no comma...&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Fran??ois-Xavier</description>
      <pubDate>Mon, 09 Dec 2002 16:18:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854846#M94467</guid>
      <dc:creator>F. X. de Montgolfier</dc:creator>
      <dc:date>2002-12-09T16:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Sed  to remove comma</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854847#M94468</link>
      <description>...or even:&lt;BR /&gt;&lt;BR /&gt;sed 's/:[^:]*$/:/' /etc/group&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin</description>
      <pubDate>Mon, 09 Dec 2002 16:45:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sed-to-remove-comma/m-p/2854847#M94468</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-12-09T16:45:24Z</dc:date>
    </item>
  </channel>
</rss>

