<?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: unix command in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017151#M129693</link>
    <description>hello all! thanks for the info! what if there is additional text after hello. let's say. &lt;BR /&gt;--testing--&lt;BR /&gt;test123 &lt;BR /&gt;--testing--&lt;BR /&gt;--hello--&lt;BR /&gt;hiya&lt;BR /&gt;--hello--&lt;BR /&gt;--world--&lt;BR /&gt;earth&lt;BR /&gt;--world--&lt;BR /&gt;&lt;BR /&gt;is there a way to delete everything starting from hello to world. so the end output will be&lt;BR /&gt;--testing--&lt;BR /&gt;test123&lt;BR /&gt;--testing--&lt;BR /&gt;&lt;BR /&gt;but without hard coding it. because I might not know what's the next block after hello. thanks so much! I'm relatively new with this. &lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 07 Jul 2003 21:19:12 GMT</pubDate>
    <dc:creator>mango_1</dc:creator>
    <dc:date>2003-07-07T21:19:12Z</dc:date>
    <item>
      <title>unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017143#M129685</link>
      <description>hello all! I'd like to ask if there's a unix command that could delete parts of the file given a string. Example:&lt;BR /&gt;Given: File1 which contains&lt;BR /&gt;--testing--&lt;BR /&gt;test123&lt;BR /&gt;--testing--&lt;BR /&gt;--hello--&lt;BR /&gt;world&lt;BR /&gt;--hello--&lt;BR /&gt;&lt;BR /&gt;If my string is hello, the output would be another file or the same file but without the hello block. So, the output would be&lt;BR /&gt;--testing--&lt;BR /&gt;test123&lt;BR /&gt;--testing--&lt;BR /&gt;&lt;BR /&gt;if anybody knows please help! thanks!</description>
      <pubDate>Mon, 07 Jul 2003 19:53:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017143#M129685</guid>
      <dc:creator>mango_1</dc:creator>
      <dc:date>2003-07-07T19:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017144#M129686</link>
      <description>The simplest, least elegant way would be:&lt;BR /&gt;&lt;BR /&gt;# grep -v hello somefile &amp;gt; some_other_file&lt;BR /&gt;&lt;BR /&gt;The above would look for all occurences of hello anywhere in a line in the file somefile and put all lines EXCEPT those in the file some_other_file.&lt;BR /&gt;&lt;BR /&gt;I'm sure others will give you examples with Perl, awk, sed, etc.  as there are lots of ways to do this.</description>
      <pubDate>Mon, 07 Jul 2003 20:01:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017144#M129686</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2003-07-07T20:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017145#M129687</link>
      <description>lets see&lt;BR /&gt;&lt;BR /&gt;cat file | sed '/^--hello--/d' &amp;gt; newFile&lt;BR /&gt;&lt;BR /&gt;cat file | awk '{if ( $0 !~ "--hello--" ) print $0;}' &amp;gt; newFile</description>
      <pubDate>Mon, 07 Jul 2003 20:02:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017145#M129687</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-07-07T20:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017146#M129688</link>
      <description>Hello!&lt;BR /&gt;&lt;BR /&gt;Use perl, read the file and write to the&lt;BR /&gt;new one all what you want from the file.&lt;BR /&gt;&lt;BR /&gt;Caesar</description>
      <pubDate>Mon, 07 Jul 2003 20:04:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017146#M129688</guid>
      <dc:creator>Caesar_3</dc:creator>
      <dc:date>2003-07-07T20:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017147#M129689</link>
      <description>and&lt;BR /&gt;&lt;BR /&gt;ex -s +"1,$ /^--hello--/ d|w!q" file1</description>
      <pubDate>Mon, 07 Jul 2003 20:08:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017147#M129689</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-07-07T20:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017148#M129690</link>
      <description>Try this which will make a NEW File1:&lt;BR /&gt;&lt;BR /&gt;# cat File1 | grep -v "--hello--" | tee File1 &amp;gt;/dev/null&lt;BR /&gt;&lt;BR /&gt;Hai</description>
      <pubDate>Mon, 07 Jul 2003 20:08:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017148#M129690</guid>
      <dc:creator>Hai Nguyen_1</dc:creator>
      <dc:date>2003-07-07T20:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017149#M129691</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;# sed -n '/--hello--/,/--hello--/!p' filename &amp;gt; filename.new&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 07 Jul 2003 20:12:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017149#M129691</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-07-07T20:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017150#M129692</link>
      <description>Do a search of the forums, using the "exact phrase" option, for "handy one liners for sed". I don't have the document available to me at the moment but I think it will provide what you seek. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Jul 2003 21:04:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017150#M129692</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2003-07-07T21:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017151#M129693</link>
      <description>hello all! thanks for the info! what if there is additional text after hello. let's say. &lt;BR /&gt;--testing--&lt;BR /&gt;test123 &lt;BR /&gt;--testing--&lt;BR /&gt;--hello--&lt;BR /&gt;hiya&lt;BR /&gt;--hello--&lt;BR /&gt;--world--&lt;BR /&gt;earth&lt;BR /&gt;--world--&lt;BR /&gt;&lt;BR /&gt;is there a way to delete everything starting from hello to world. so the end output will be&lt;BR /&gt;--testing--&lt;BR /&gt;test123&lt;BR /&gt;--testing--&lt;BR /&gt;&lt;BR /&gt;but without hard coding it. because I might not know what's the next block after hello. thanks so much! I'm relatively new with this. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Jul 2003 21:19:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017151#M129693</guid>
      <dc:creator>mango_1</dc:creator>
      <dc:date>2003-07-07T21:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017152#M129694</link>
      <description>can you provide a definition for what a "block" of output is.  or a relationship between hello and world that is going to be deleted.</description>
      <pubDate>Mon, 07 Jul 2003 21:32:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017152#M129694</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-07-07T21:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017153#M129695</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;For your last question, examine the input you have.  Now, you want only the block bounded, inclusively by "---testing--" and "---testing---".  This is similar to the first solutipm I offered, but without negating (with the '!' flag)the 'p'rint:&lt;BR /&gt;&lt;BR /&gt;# sed -n '/--testing/,/--testing/p' filein &amp;gt; fileout&lt;BR /&gt;&lt;BR /&gt;This says, "dont print (output) anything, except, (p)rint that which begins (and ends) with the regular expression /--testing/.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 07 Jul 2003 23:27:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017153#M129695</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-07-07T23:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017154#M129696</link>
      <description>Hi,&lt;BR /&gt;Do you mean from the first "hello" to last "world", all lines be deleted?&lt;BR /&gt;&lt;BR /&gt;-ux&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Jul 2003 23:29:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017154#M129696</guid>
      <dc:creator>Fragon</dc:creator>
      <dc:date>2003-07-07T23:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017155#M129697</link>
      <description>hi thanks for the help everyone. &lt;BR /&gt;&lt;BR /&gt;curt: a block is those lines enclosing the &lt;BR /&gt;--xxxxxx---&lt;BR /&gt;hello&lt;BR /&gt;world&lt;BR /&gt;--xxxxxx---&lt;BR /&gt;&lt;BR /&gt;james: thanks for the help. I have another question to that. what if the file contains&lt;BR /&gt;--abc--&lt;BR /&gt;def&lt;BR /&gt;--abc--&lt;BR /&gt;--testing--&lt;BR /&gt;123&lt;BR /&gt;--testing--&lt;BR /&gt;--hello--&lt;BR /&gt;world&lt;BR /&gt;--hello--&lt;BR /&gt;--mango--&lt;BR /&gt;fruit&lt;BR /&gt;--mango--&lt;BR /&gt;&lt;BR /&gt;then output the following&lt;BR /&gt;--abc--&lt;BR /&gt;def&lt;BR /&gt;--abc--&lt;BR /&gt;--testing--&lt;BR /&gt;123&lt;BR /&gt;--testing--&lt;BR /&gt;where you only know testing string and not the abc. could i use sed -n ...1,/--testing--/. hmmm...&lt;BR /&gt;&lt;BR /&gt;thanks again everyone.</description>
      <pubDate>Wed, 09 Jul 2003 12:04:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017155#M129697</guid>
      <dc:creator>mango_1</dc:creator>
      <dc:date>2003-07-09T12:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017156#M129698</link>
      <description>hpux: I meant from the whole block of hello&lt;BR /&gt;just &lt;BR /&gt;--hello--&lt;BR /&gt;world&lt;BR /&gt;--hello--</description>
      <pubDate>Wed, 09 Jul 2003 12:07:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017156#M129698</guid>
      <dc:creator>mango_1</dc:creator>
      <dc:date>2003-07-09T12:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017157#M129699</link>
      <description>hi james! one last question please. what can I do to not include the --testing-- headers for example&lt;BR /&gt;&lt;BR /&gt;I have this file format:&lt;BR /&gt;--abc--&lt;BR /&gt;def&lt;BR /&gt;--testing--&lt;BR /&gt;123&lt;BR /&gt;--hello--&lt;BR /&gt;world&lt;BR /&gt;&lt;BR /&gt;then &lt;BR /&gt;&lt;BR /&gt;sed -n '1,/--testing--/p' file19 &amp;gt; file23&lt;BR /&gt;&lt;BR /&gt;will print out&lt;BR /&gt;--abc--&lt;BR /&gt;def&lt;BR /&gt;--testing--&lt;BR /&gt;&lt;BR /&gt;is there a way to remove the --testing-- being printed out to the new file? eg&lt;BR /&gt;--abc--&lt;BR /&gt;def&lt;BR /&gt;&lt;BR /&gt;or should I just reformat my file. hmmm&lt;BR /&gt;&lt;BR /&gt;is there a way to manipulate the same file? in this case file19 without having to redirect the output to another file? just wondering. thanks!</description>
      <pubDate>Wed, 09 Jul 2003 12:17:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017157#M129699</guid>
      <dc:creator>mango_1</dc:creator>
      <dc:date>2003-07-09T12:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017158#M129700</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;In answer to your question about using:&lt;BR /&gt;&lt;BR /&gt;# sed -n '1,/--testing--/p' filein &amp;gt; fileout&lt;BR /&gt;&lt;BR /&gt;...that is legitimate syntax for "from record #1 through (inclusive) a record with the regular expression /--testing--/ print the output.  Using your file, though as posted, you would get only this:&lt;BR /&gt;&lt;BR /&gt;--abc--&lt;BR /&gt;def&lt;BR /&gt;--abc--&lt;BR /&gt;--testing--&lt;BR /&gt;&lt;BR /&gt;If you want to extract the "blocks" /--abc--/ *and* /--testing--/ I suggest you do something like this:&lt;BR /&gt;&lt;BR /&gt;# sed -n '/--abc--/,/--abc--/p' filein &amp;gt; fileout&lt;BR /&gt;&lt;BR /&gt;# sed -n '/--testing--/,/--testing--/p' filein &amp;gt;&amp;gt; fileout&lt;BR /&gt;&lt;BR /&gt;...that is, make two passes with the same input file, *appending* the second pass to the output of the first.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 09 Jul 2003 12:28:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017158#M129700</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-07-09T12:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017159#M129701</link>
      <description>Hi Mango:&lt;BR /&gt;&lt;BR /&gt;With regard to your last question..."to not include the --testing-- headers", here's one approach:&lt;BR /&gt;&lt;BR /&gt;# V=--testing---&lt;BR /&gt;# sed -n "/${V}/,/${V}/p" filein|grep -v \\${V}&lt;BR /&gt;&lt;BR /&gt;Note carefully the two backslashes before the ${V} variable in the 'grep' pipeline.  Without these, 'grep' will not interpret the "--testing--" expression correctly.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 09 Jul 2003 13:06:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017159#M129701</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-07-09T13:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017160#M129702</link>
      <description>thanks james! that really solved my problem. :) Is there a way to manipulate the same file. I don't know if its going to be inefficient to create another file when I'm just editing the same file. thanks! &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Jul 2003 15:28:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017160#M129702</guid>
      <dc:creator>mango_1</dc:creator>
      <dc:date>2003-07-10T15:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017161#M129703</link>
      <description>is this possible&lt;BR /&gt;&lt;BR /&gt;test="==testin=="&lt;BR /&gt;sed -n "1,/==$test==/p" file | grep -v \\$test &amp;gt; file&lt;BR /&gt;&lt;BR /&gt;thanks</description>
      <pubDate>Thu, 10 Jul 2003 19:11:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017161#M129703</guid>
      <dc:creator>mango_1</dc:creator>
      <dc:date>2003-07-10T19:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: unix command</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017162#M129704</link>
      <description>Hi Mango:&lt;BR /&gt;&lt;BR /&gt;I think you wanted to write:&lt;BR /&gt;&lt;BR /&gt;# test="==testin=="&lt;BR /&gt;# sed -n "1,/$test/p" file|grep -v \\$test &amp;gt; file&lt;BR /&gt;&lt;BR /&gt;That is, from record-1 through a record with the string ==testin== ...&lt;BR /&gt;&lt;BR /&gt;...and the answer is *NO* you can't.  You need to use an intermediate file.  In the above, you will end up with an empry file.  You cannot edit inplace nor can you read and write to the same file (which is what the above pipeline does!&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 10 Jul 2003 20:26:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/unix-command/m-p/3017162#M129704</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2003-07-10T20:26:35Z</dc:date>
    </item>
  </channel>
</rss>

