<?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 command - specifying multiple delimiters in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768505#M260809</link>
    <description>Hi Hein,&lt;BR /&gt;&lt;BR /&gt;I tried your method using PERL but I obtained the error below:&lt;BR /&gt;&lt;BR /&gt;prod-cingkl-linux01\ :/nfs/users/lows&amp;gt;perl -ne "print "$1 $2 $3 $4 $5 $6\n" if /^(\w+).(\w+)-(\w+)_(.*)_(\w+).(\w+)/" f1&lt;BR /&gt;Can't open n if /^(\w+).(\w+)-(\w+)_(.*)_(\w+).(\w+)/: No such file or directory.&lt;BR /&gt;A20060405.0011-0032_SubNetwork=SE,SubNetwork=RNC203,MeContext=RNC203_statsfile.xml&lt;BR /&gt;prod-cingkl-linux01\ :/nfs/users/lows &amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I've also tried doing:&lt;BR /&gt;cat f1|perl -ne "print "$1 $2 $3 $4 $5 $6\n" if /^(\w+).(\w+)-(\w+)_(.*)_(\w+).(\w+)/"&lt;BR /&gt;Can't open n if /^(\w+).(\w+)-(\w+)_(.*)_(\w+).(\w+)/: No such file or directory.&lt;BR /&gt;A20060405.0011-0032_SubNetwork=SE,SubNetwork=RNC203,MeContext=RNC203_statsfile.xml&lt;BR /&gt;prod-cingkl-linux01\ :/nfs/users/lows &amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Could you point out to me where did I go wrong in this implementation?</description>
    <pubDate>Tue, 11 Apr 2006 02:52:18 GMT</pubDate>
    <dc:creator>Danny Fang</dc:creator>
    <dc:date>2006-04-11T02:52:18Z</dc:date>
    <item>
      <title>cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768491#M260795</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm attempting to use the "cut" command to extract elements from the filename having the form shown below:&lt;BR /&gt;A20051109.0215-0230_SubNetwork=ONRM_RootMo,SubNetwork=SNTDCAUJRNC002,MeContext=SNTDCAUJRNC002_statsfile.xml&lt;BR /&gt;&lt;BR /&gt;I'd want to extract the following elements:&lt;BR /&gt;1) A20051109&lt;BR /&gt;2) 0215&lt;BR /&gt;3) 0230&lt;BR /&gt;4)SubNetwork=ONRM_RootMo,SubNetwork=SNTDCAUJRNC002,MeContext=SNTDCAUJRNC002&lt;BR /&gt;5) statsfile&lt;BR /&gt;6) xml&lt;BR /&gt;&lt;BR /&gt;I've tried using "cut" in the following way, but it did not do the trick.&lt;BR /&gt;&lt;BR /&gt;ls A20051109.0215-0230_SubNetwork=ONRM_RootMo,SubNetwork=SNTDCAUJRNC002,MeContext=SNTDCAUJRNC002_statsfile.xml |cut -f1-6 -d".,-"&lt;BR /&gt;cut: invalid delimiter&lt;BR /&gt;bash-3.00$&lt;BR /&gt;&lt;BR /&gt;I've also tried using single quotes as in '.,-,_' to the -d option but it produced the same error shown above. &lt;BR /&gt;&lt;BR /&gt;How do I specify multiple delimiters to the "cut" -d option?&lt;BR /&gt;&lt;BR /&gt;Also, how do I assign each element obtained through "cut" into their respective variable names in a script?&lt;BR /&gt;&lt;BR /&gt;Could anyone help show me how it's done?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Sun, 09 Apr 2006 05:47:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768491#M260795</guid>
      <dc:creator>Danny Fang</dc:creator>
      <dc:date>2006-04-09T05:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768492#M260796</link>
      <description>Hi Danny:&lt;BR /&gt;&lt;BR /&gt;A llok at the manpages for 'cut' will show you that the delimiter ('-d') switch supports only a simple character argument.&lt;BR /&gt;&lt;BR /&gt;You asked "How do I specify multiple delimiters to the "cut" -d option?".  Consider :&lt;BR /&gt;&lt;BR /&gt;# echo "a b|c d"|cut -d " " -f2|cut -d"|" -f2&lt;BR /&gt;&lt;BR /&gt;...this extracts the "c" from the input string.  We need to do two 'cut's each with a different delimiter.&lt;BR /&gt;&lt;BR /&gt;To assign the extracted value to a variable, simply do:&lt;BR /&gt;&lt;BR /&gt;# VAR=`echo "a b|c d"|cut -d " " -f2|cut -d"|" -f2`&lt;BR /&gt;&lt;BR /&gt;# echo ${VAR} #...to see the value.&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, 09 Apr 2006 08:51:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768492#M260796</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-04-09T08:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768493#M260797</link>
      <description>Change the delimeters to all be the same before using cut.... I chose spaces then awk will delimit on space without setting field seperator - so no cut required". Read directly in to variables.&lt;BR /&gt;&lt;BR /&gt;e.g. &lt;BR /&gt;echo "XX.yy,zz-aa,bb" |sed &lt;BR /&gt;"s/\,/\ /g&lt;BR /&gt;s/-/ /g" |awk '{print $1, $2, $3}' |read VAR1 VAR2 VAR3&lt;BR /&gt;&lt;BR /&gt;If you like you can use this with cut as before but only need to use one type.</description>
      <pubDate>Mon, 10 Apr 2006 06:26:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768493#M260797</guid>
      <dc:creator>jon2</dc:creator>
      <dc:date>2006-04-10T06:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768494#M260798</link>
      <description>With a decently complicated sed you can parse and reconstruct, replacing the delimiters with spaces:&lt;BR /&gt;&lt;BR /&gt;sed "s/^\(.*\)\.\(.*\)\-\(.*\)\_\(.*\)\_\(.*\)\_\(.*\)\.\(.*\)/\1 \2 \3 \4_\5 \6 \7/"&lt;BR /&gt;&lt;BR /&gt;thus &lt;BR /&gt;&lt;BR /&gt;echo A20051109.0215-0230_SubNetwork=ONRM_RootMo,SubNetwork=SNTDCAUJRNC002,MeContext=SNTDCAUJRNC002_statsfile.xml | sed "s/^\(.*\)\.\(.*\)\-\(.*\)\_\(.*\)\_\(.*\)\_\(.*\)\.\(.*\)/\1 \2 \3 \4_\5 \6 \7/"&lt;BR /&gt;&lt;BR /&gt;produces&lt;BR /&gt;&lt;BR /&gt;A20051109 0215 0230 SubNetwork=ONRM_RootMo,SubNetwork=SNTDCAUJRNC002,MeContext=SNTDCAUJRNC002 statsfile xml&lt;BR /&gt;&lt;BR /&gt;Note that I had to reinsert the underscore (_) in the "SubNetwork" string.&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry d brown jr&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Apr 2006 06:45:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768494#M260798</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2006-04-10T06:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768495#M260799</link>
      <description>Your problem will be the ","&lt;BR /&gt;For some parts of the string this is apparently desired to be a seperator, but not for all. You'll need (perl) logic to fix that.&lt;BR /&gt;&lt;BR /&gt;Just doing the split is easy in perl:&lt;BR /&gt;&lt;BR /&gt;#cat file1.tmp&lt;BR /&gt;A20051109.0215-0230_SubNetwork=ONRM_RootMo,SubNetwork=SNTDCAUJRNC002,MeContext=SNTDCAUJRNC002_statsfile.xml&lt;BR /&gt;#&lt;BR /&gt;#perl -ne "foreach $x (split /[.,\-_]/) {print \"$x\n\"}" file1.tmp&lt;BR /&gt;A20051109&lt;BR /&gt;0215&lt;BR /&gt;0230&lt;BR /&gt;SubNetwork=ONRM&lt;BR /&gt;RootMo&lt;BR /&gt;SubNetwork=SNTDCAUJRNC002&lt;BR /&gt;MeContext=SNTDCAUJRNC002&lt;BR /&gt;statsfile&lt;BR /&gt;xml&lt;BR /&gt;&lt;BR /&gt;btw... you can pass the the seperators on the command line with -F, anf perl (like awk) has build-ins for auto split fields.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.</description>
      <pubDate>Mon, 10 Apr 2006 06:58:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768495#M260799</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-04-10T06:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768496#M260800</link>
      <description>Do not forget that where the delimiter is desired to be a "_" and has been made a space it can be reconstructed with the variables when they are used. (no perl etc required). &lt;BR /&gt;&lt;BR /&gt;e.g  echo "${VAR2}_${VAR3}....</description>
      <pubDate>Mon, 10 Apr 2006 07:12:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768496#M260800</guid>
      <dc:creator>jon2</dc:creator>
      <dc:date>2006-04-10T07:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768497#M260801</link>
      <description>To assign the "fields" into script variables you could do this:&lt;BR /&gt;&lt;BR /&gt;create a script:&lt;BR /&gt;&lt;BR /&gt;somescript.ksh&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;#&lt;BR /&gt;while read aline&lt;BR /&gt;do&lt;BR /&gt;echo $aline | sed "s/^\(.*\)\.\(.*\)\-\(.*\)\_\(.*\)\_\(.*\)\_\(.*\)\.\(.*\)/\1 \2 \3 \4_\5 \6 \7/"|read var1 var2 var3 var4 var5 var6&lt;BR /&gt;echo var1=$var1&lt;BR /&gt;echo var2=$var2&lt;BR /&gt;echo var3=$var3&lt;BR /&gt;echo var4=$var4&lt;BR /&gt;echo var5=$var5&lt;BR /&gt;echo var6=$var6&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;chmod a+x somescript.ksh&lt;BR /&gt;&lt;BR /&gt;cat yourdata | ./somescript.ksh&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry d brown jr</description>
      <pubDate>Mon, 10 Apr 2006 07:50:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768497#M260801</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2006-04-10T07:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768498#M260802</link>
      <description>Harry,&lt;BR /&gt;     Do you mean like in my sample at 11.26 am ?&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Apr 2006 08:05:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768498#M260802</guid>
      <dc:creator>jon2</dc:creator>
      <dc:date>2006-04-10T08:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768499#M260803</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;if you like a solution using shell features only (I did this in ksh):&lt;BR /&gt;&lt;BR /&gt;name='A20051109.0215-0230_SubNetwork=ONRM_RootMo,SubNetwork=SNTDCAUJRNC&lt;BR /&gt;002,MeContext=SNTDCAUJRNC002_statsfile.xml'&lt;BR /&gt;p1=${name%%.*}&lt;BR /&gt;remain=${name#$p1.}&lt;BR /&gt;p2=${remain%%-*}&lt;BR /&gt;remain=${remain#$p2-}&lt;BR /&gt;p3=${remain%%_*}&lt;BR /&gt;remain=${remain#${p3}_}&lt;BR /&gt;p4=${remain%_*}&lt;BR /&gt;remain=${remain#${p4}_}&lt;BR /&gt;p5=${remain%.*}&lt;BR /&gt;p6=${remain#*.}&lt;BR /&gt;&lt;BR /&gt;print $name;print $p1;print $p2;print $p3;print $p4;print $p5;print $p6&lt;BR /&gt;&lt;BR /&gt;A20051109.0215-0230_SubNetwork=ONRM_RootMo,SubNetwork=SNTDCAUJRNC002,MeContext=SNTDCAUJRNC002_statsfile.xml&lt;BR /&gt;A20051109&lt;BR /&gt;0215&lt;BR /&gt;0230&lt;BR /&gt;SubNetwork=ONRM_RootMo,SubNetwork=SNTDCAUJRNC002,MeContext=SNTDCAUJRNC002&lt;BR /&gt;statsfile&lt;BR /&gt;xml&lt;BR /&gt;&lt;BR /&gt;The variables p1...p6 will contain the requested values (watch for the correct string operators!).&lt;BR /&gt;&lt;BR /&gt;mfG Peter&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Apr 2006 08:11:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768499#M260803</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2006-04-10T08:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768500#M260804</link>
      <description>jon2,&lt;BR /&gt;&lt;BR /&gt;close if you consider the use of the "read" statement, but the examples I provided do the following:&lt;BR /&gt;- without the use of awk or perl (not that there is anything wrong with them)&lt;BR /&gt;- use of pattern matching&lt;BR /&gt;- providing all SIX desired output fields&lt;BR /&gt;- example of putting the code in a loop&lt;BR /&gt;&lt;BR /&gt;BTW, you wouldn't be claiming plagurisim, would you?&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry d brown jr</description>
      <pubDate>Mon, 10 Apr 2006 08:24:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768500#M260804</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2006-04-10T08:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768501#M260805</link>
      <description>Harry, Good points!&lt;BR /&gt;&lt;BR /&gt;Peter, Excellent solution if the data is in a shell variable already and the results need to be in shell variable.&lt;BR /&gt;Note that often these questions are really only a small part of a large file based data processing and I find it more efficient to stay in perl or awk longer and do all of the string manipulation there before going back to the shel or into a shell (system call)&lt;BR /&gt;&lt;BR /&gt;jon2 at Apr 10, 2006 13:05:01 GMT wrote:    &amp;gt; Harry, Do you mean like in my sample at 11.26 am ?&lt;BR /&gt;&lt;BR /&gt;Jon2, how does your solution solve part 4) ?&lt;BR /&gt;It seems to me that would be fragemented (like my solution).&lt;BR /&gt;&lt;BR /&gt;Hein, &lt;BR /&gt;This part is broken: print \"$x\n\"&lt;BR /&gt;On hpux it should simply be: print "$x\n"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Danny,&lt;BR /&gt;Similar solution as Harry, but in with perl:&lt;BR /&gt;&lt;BR /&gt;#perl -ne "print "$1 $2 $3 $4 $5 $6\n" if /^(\w+).(\w+)-(\w+)_(.*)_(\w+).(\w+)/" file1.tmp&lt;BR /&gt;&lt;BR /&gt;A20051109 0215 0230 &lt;BR /&gt;SubNetwork=ONRM_RootMo,SubNetwork=SNTDCAUJRNC002,MeContext=SNTDCAUJRNC002 statsfile xml&lt;BR /&gt;&lt;BR /&gt;You can of course 'echo/print' the intiable variable into perl when not using data from a file, and 'read' its output into shell variables if no further processing is needed.&lt;BR /&gt; &lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Apr 2006 09:56:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768501#M260805</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-04-10T09:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768502#M260806</link>
      <description>Harry,&lt;BR /&gt;&lt;BR /&gt; I was only highliting that &lt;BR /&gt;'To assign the "fields" into script variables you could' - use the technique I had shown.  &lt;BR /&gt;&lt;BR /&gt;You are correct I used awk, no pattern match and my variables only went up to VAR3, and not knowing the source of the line to parse did not put it in an actual  script. &lt;BR /&gt;&lt;BR /&gt;Hein I had not offered a "full solution" as I had not logged on to try it....but now I have had to...&lt;BR /&gt;&lt;BR /&gt;Mine would deal with 4 as follows:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;cat /tmp/inputfile |sed "s/\./,/g&lt;BR /&gt;s/_/,/&lt;BR /&gt;s/_/\#/g&lt;BR /&gt;s/\#/_/&lt;BR /&gt;s/-/,/&lt;BR /&gt;s/\#/,/" |awk -F, '{print $1,$2,$3,$4,$5,$6,$7,$8}' | read VAR1 VAR2 VAR3 VAR4 VAR5 VAR6 VAR7 VAR8&lt;BR /&gt;&lt;BR /&gt;I guess that the awk could be removed and spaces used not "," and the output read direct into the variables. but there you go.  Why I always use awk in that way I will never know.. habit I guess, along with avoiding using pattern matches. &lt;BR /&gt; &lt;BR /&gt;&lt;I cannot="" paste="" so="" if="" it="" fails="" to="" run..its="" a="" typo.....="" and="" it="" is="" probably="" the="" least="" elegant="" solution="" on="" this="" thread=""&gt;.&lt;BR /&gt;&lt;BR /&gt;&lt;/I&gt;</description>
      <pubDate>Mon, 10 Apr 2006 15:10:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768502#M260806</guid>
      <dc:creator>jon2</dc:creator>
      <dc:date>2006-04-10T15:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768503#M260807</link>
      <description>How about using awk:&lt;BR /&gt;&lt;BR /&gt;# awk -F"." '{&lt;BR /&gt;&amp;gt; split($2,z,"_")&lt;BR /&gt;&amp;gt; split(z[1],x,"-")&lt;BR /&gt;&amp;gt; printf("%s\n%s\n%s\n%s_%s\n%s\n%s\n",$1,x[1],x[2],z[2],z[3],z[4],$NF)&lt;BR /&gt;&amp;gt; }' your_file&lt;BR /&gt;&lt;BR /&gt;cheers!</description>
      <pubDate>Mon, 10 Apr 2006 16:34:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768503#M260807</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-04-10T16:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768504#M260808</link>
      <description>Hi Harry,&lt;BR /&gt;&lt;BR /&gt;I tried executing the example which you provided:&lt;BR /&gt;somescript.ksh &lt;BR /&gt;#!/usr/bin/ksh &lt;BR /&gt;# &lt;BR /&gt;while read aline &lt;BR /&gt;do &lt;BR /&gt;echo $aline | sed "s/^\(.*\)\.\(.*\)\-\(.*\)\_\(.*\)\_\(.*\)\_\(.*\)\.\(.*\)/\1 \2 \3 \4_\5 \6 \7/"|read var1 var2 var3 var4 var5 var6 &lt;BR /&gt;echo var1=$var1 &lt;BR /&gt;echo var2=$var2 &lt;BR /&gt;echo var3=$var3 &lt;BR /&gt;echo var4=$var4 &lt;BR /&gt;echo var5=$var5 &lt;BR /&gt;echo var6=$var6 &lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;chmod a+x somescript.ksh &lt;BR /&gt;&lt;BR /&gt;cat yourdata | ./somescript.ksh &lt;BR /&gt;&lt;BR /&gt;OUTPUT:&lt;BR /&gt;var1 is&lt;BR /&gt;var2 is&lt;BR /&gt;var3 is&lt;BR /&gt;var4 is&lt;BR /&gt;var5 is&lt;BR /&gt;var6 is&lt;BR /&gt;&lt;BR /&gt;and also:&lt;BR /&gt;&lt;BR /&gt;echo A20051109.0215-0230_SubNetwork=ONRM_RootMo,SubNetwork=SNTDCAUJRNC0&lt;BR /&gt;02,MeContext=SNTDCAUJRNC002_statsfile.xml | sed "s/^\(.*\)\.\(.*\)\-\(.*\)\_\(.*\)\_\(.*\)\_\(.*\)\.\(.*\)/\1 \2 \3 \4_\5 \6 \7/" |read var1 var2 var3 var4 var5 var6 echo var1 is $var1&lt;BR /&gt;echo var2 is $var2&lt;BR /&gt;echo var3 is $var3&lt;BR /&gt;echo var4 is $var4&lt;BR /&gt;echo var5 is $var5&lt;BR /&gt;echo var6 is $var6&lt;BR /&gt;&lt;BR /&gt;var1 is&lt;BR /&gt;var2 is&lt;BR /&gt;var3 is&lt;BR /&gt;var4 is&lt;BR /&gt;var5 is&lt;BR /&gt;var6 is&lt;BR /&gt;&lt;BR /&gt;I'm unable to obtain the output to the values var1, var2, var3, var4, var5 and var6.&lt;BR /&gt;&lt;BR /&gt;Could you point out to me where did I go wrong?&lt;BR /&gt;&lt;BR /&gt;I tried the other methods posted in this forum and they all work. However, I'd also like to understand your method of using sed to achieve the results. &lt;BR /&gt;&lt;BR /&gt;Could you help out?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Apr 2006 02:45:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768504#M260808</guid>
      <dc:creator>Danny Fang</dc:creator>
      <dc:date>2006-04-11T02:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768505#M260809</link>
      <description>Hi Hein,&lt;BR /&gt;&lt;BR /&gt;I tried your method using PERL but I obtained the error below:&lt;BR /&gt;&lt;BR /&gt;prod-cingkl-linux01\ :/nfs/users/lows&amp;gt;perl -ne "print "$1 $2 $3 $4 $5 $6\n" if /^(\w+).(\w+)-(\w+)_(.*)_(\w+).(\w+)/" f1&lt;BR /&gt;Can't open n if /^(\w+).(\w+)-(\w+)_(.*)_(\w+).(\w+)/: No such file or directory.&lt;BR /&gt;A20060405.0011-0032_SubNetwork=SE,SubNetwork=RNC203,MeContext=RNC203_statsfile.xml&lt;BR /&gt;prod-cingkl-linux01\ :/nfs/users/lows &amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I've also tried doing:&lt;BR /&gt;cat f1|perl -ne "print "$1 $2 $3 $4 $5 $6\n" if /^(\w+).(\w+)-(\w+)_(.*)_(\w+).(\w+)/"&lt;BR /&gt;Can't open n if /^(\w+).(\w+)-(\w+)_(.*)_(\w+).(\w+)/: No such file or directory.&lt;BR /&gt;A20060405.0011-0032_SubNetwork=SE,SubNetwork=RNC203,MeContext=RNC203_statsfile.xml&lt;BR /&gt;prod-cingkl-linux01\ :/nfs/users/lows &amp;gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Could you point out to me where did I go wrong in this implementation?</description>
      <pubDate>Tue, 11 Apr 2006 02:52:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768505#M260809</guid>
      <dc:creator>Danny Fang</dc:creator>
      <dc:date>2006-04-11T02:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768506#M260810</link>
      <description>Hi Danny,&lt;BR /&gt;&lt;BR /&gt;That's because you need a newline before echo'ing the variables. Harry's command works but something may have been lost during the copy and paste.&lt;BR /&gt;&lt;BR /&gt;Change...&lt;BR /&gt;read var1 var2 var3 var4 var5 var6 echo var1 is $var1&lt;BR /&gt;To...&lt;BR /&gt;read var1 var2 var3 var4 var5 var6&lt;BR /&gt;echo var1 is $var1&lt;BR /&gt;&lt;BR /&gt;cheers!</description>
      <pubDate>Tue, 11 Apr 2006 02:59:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768506#M260810</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-04-11T02:59:29Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768507#M260811</link>
      <description>Hi Sandman,&lt;BR /&gt;&lt;BR /&gt;Attached is my script according to Harry's.&lt;BR /&gt;&lt;BR /&gt;I do have the echo separated from line &lt;BR /&gt;read var1 var2 var3 var4 var5 var6 &lt;BR /&gt;&lt;BR /&gt;However, it's still not able to print the values in var1, var2, var3, var4, var5 and var6. &lt;BR /&gt;&lt;BR /&gt;prod-cingkl-linux01\ :/nfs/users/lows &amp;gt;./testSed1.sh&lt;BR /&gt;var1 is&lt;BR /&gt;var2 is&lt;BR /&gt;var3 is&lt;BR /&gt;var4 is&lt;BR /&gt;var5 is&lt;BR /&gt;var6 is&lt;BR /&gt;&lt;BR /&gt;Could you help point out where did I go wrong?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Apr 2006 03:25:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768507#M260811</guid>
      <dc:creator>Danny Fang</dc:creator>
      <dc:date>2006-04-11T03:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768508#M260812</link>
      <description>Danny,&lt;BR /&gt;&lt;BR /&gt;Run the sed script in debug mode and see what's wrong with it?&lt;BR /&gt;&lt;BR /&gt;# ksh -x ./testSed1.sh&lt;BR /&gt;&lt;BR /&gt;I copied the script into a file on my system and it worked.</description>
      <pubDate>Tue, 11 Apr 2006 04:22:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768508#M260812</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2006-04-11T04:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768509#M260813</link>
      <description>Hi Sandman, &lt;BR /&gt;&lt;BR /&gt;The output of the script in debug mode:&lt;BR /&gt;&lt;BR /&gt;prod-cingkl-linux01\ :/nfs/users/lows &amp;gt;ksh -x ./testSed1.sh&lt;BR /&gt;+ echo A20051109.0215-0230_SubNetwork=ONRM_RootMo,SubNetwork=SNTDCAUJRNC002,MeContext=SNTDCAUJRNC002_statsfile.xml&lt;BR /&gt;+ sed s/^\(.*\)\.\(.*\)\-\(.*\)\_\(.*\)\_\(.*\)\_\(.*\)\.\(.*\)/\1 \2 \3 \4_\5 \6 \7/&lt;BR /&gt;+ read var1 var2 var3 var4 var5 var6&lt;BR /&gt;+ echo var1 is&lt;BR /&gt;var1 is&lt;BR /&gt;+ echo var2 is&lt;BR /&gt;var2 is&lt;BR /&gt;+ echo var3 is&lt;BR /&gt;var3 is&lt;BR /&gt;+ echo var4 is&lt;BR /&gt;var4 is&lt;BR /&gt;+ echo var5 is&lt;BR /&gt;var5 is&lt;BR /&gt;+ echo var6 is&lt;BR /&gt;var6 is&lt;BR /&gt;prod-cingkl-linux01\ :/nfs/users/lows &amp;gt;&lt;BR /&gt;&lt;BR /&gt;I can't seem to detect where the error is.&lt;BR /&gt;&lt;BR /&gt;Could you help out?&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 11 Apr 2006 05:24:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768509#M260813</guid>
      <dc:creator>Danny Fang</dc:creator>
      <dc:date>2006-04-11T05:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: cut command - specifying multiple delimiters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768510#M260814</link>
      <description>Try without the &lt;BR /&gt;|read .........&lt;BR /&gt;and the echos as the read behaves differently under Linux to HP-UX.</description>
      <pubDate>Tue, 11 Apr 2006 05:29:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-command-specifying-multiple-delimiters/m-p/3768510#M260814</guid>
      <dc:creator>jon2</dc:creator>
      <dc:date>2006-04-11T05:29:10Z</dc:date>
    </item>
  </channel>
</rss>

