<?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: cut the last few character(s) in a word in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/cut-the-last-few-character-s-in-a-word/m-p/3693492#M21060</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;you can use tr utility:&lt;BR /&gt;ex:&lt;BR /&gt;echo sclk_ap3  | tr -d [:digit:]</description>
    <pubDate>Sat, 17 Dec 2005 11:16:04 GMT</pubDate>
    <dc:creator>Slawomir Gora</dc:creator>
    <dc:date>2005-12-17T11:16:04Z</dc:date>
    <item>
      <title>cut the last few character(s) in a word</title>
      <link>https://community.hpe.com/t5/operating-system-linux/cut-the-last-few-character-s-in-a-word/m-p/3693491#M21059</link>
      <description>Hi &lt;BR /&gt;&lt;BR /&gt;Anybody know how to cut last few character(s) &lt;BR /&gt;from a word. &lt;BR /&gt;&lt;BR /&gt;I have sclap1,scl_ap2,sclk_ap3...sclok_ap20. and want to cut 1,2...20. or atleast ap1,ap2,....ap20&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Sajeesh&lt;BR /&gt;</description>
      <pubDate>Sat, 17 Dec 2005 11:05:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/cut-the-last-few-character-s-in-a-word/m-p/3693491#M21059</guid>
      <dc:creator>Sajeesh O.K</dc:creator>
      <dc:date>2005-12-17T11:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: cut the last few character(s) in a word</title>
      <link>https://community.hpe.com/t5/operating-system-linux/cut-the-last-few-character-s-in-a-word/m-p/3693492#M21060</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;you can use tr utility:&lt;BR /&gt;ex:&lt;BR /&gt;echo sclk_ap3  | tr -d [:digit:]</description>
      <pubDate>Sat, 17 Dec 2005 11:16:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/cut-the-last-few-character-s-in-a-word/m-p/3693492#M21060</guid>
      <dc:creator>Slawomir Gora</dc:creator>
      <dc:date>2005-12-17T11:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: cut the last few character(s) in a word</title>
      <link>https://community.hpe.com/t5/operating-system-linux/cut-the-last-few-character-s-in-a-word/m-p/3693493#M21061</link>
      <description>&lt;BR /&gt;Is the input all on one line?&lt;BR /&gt;Always comma seperated?&lt;BR /&gt;&lt;BR /&gt;If you just want those numbers, then you could delete anything else using tr -d.&lt;BR /&gt;For example:&lt;BR /&gt;&lt;BR /&gt;$ cat x&lt;BR /&gt;clap1,scl_ap2,sclk_ap3,...sclok_ap20&lt;BR /&gt;$ cat x | tr -d "_a-z"&lt;BR /&gt;1,2,3,...20&lt;BR /&gt;&lt;BR /&gt;Same thing using perl, where you can use samrter regexpr as needed (not used here):&lt;BR /&gt;&lt;BR /&gt;$perl -pe 's/[_a-z]*//g' x&lt;BR /&gt;&lt;BR /&gt;Often I find i need a bit more logic and would prefer to deal with each line and each 'word'. In perl that could look like:&lt;BR /&gt;&lt;BR /&gt;$ perl -ne 'foreach $word(split /,/)&lt;BR /&gt;{ $word =~ s/^(\D*)//; print "$word\n"}' x&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;20&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The -ne is an implied loop over the input lines reading into $_&lt;BR /&gt;&lt;BR /&gt;The foreach loops through the result of a split on the default $_ assigning to $word&lt;BR /&gt;&lt;BR /&gt;The block first performs a subsitute on $word, then prints.&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 18 Dec 2005 14:55:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/cut-the-last-few-character-s-in-a-word/m-p/3693493#M21061</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-12-18T14:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: cut the last few character(s) in a word</title>
      <link>https://community.hpe.com/t5/operating-system-linux/cut-the-last-few-character-s-in-a-word/m-p/3693494#M21062</link>
      <description>You can try like,&lt;BR /&gt;&lt;BR /&gt;# cat file&lt;BR /&gt;sclap1&lt;BR /&gt;scl_ap2&lt;BR /&gt;sclk_ap3&lt;BR /&gt;sclok_ap20&lt;BR /&gt;# sed 's/^.*\([a-z][a-z].*\)/\1/' file&lt;BR /&gt;ap1&lt;BR /&gt;ap2&lt;BR /&gt;ap3&lt;BR /&gt;ap20&lt;BR /&gt;&lt;BR /&gt;-Muthu</description>
      <pubDate>Mon, 19 Dec 2005 00:21:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/cut-the-last-few-character-s-in-a-word/m-p/3693494#M21062</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-12-19T00:21:07Z</dc:date>
    </item>
  </channel>
</rss>

