<?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, grep etc.... in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-grep-etc/m-p/2865247#M821365</link>
    <description>&lt;BR /&gt;Where /tmp/ooo is your INPUT file:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;cd /tmp&lt;BR /&gt;rm abcd*&lt;BR /&gt;csplit -s -f abcd -n 4 /tmp/ooo '/^\*\*\*\*\*\*\*\*\*\*\*\* END \*\*\*\*\*\*\*\*&lt;BR /&gt;\*\*\*\*$/+1' {*}&lt;BR /&gt;for i in `ls abcd*`&lt;BR /&gt;do&lt;BR /&gt;crazy=""&lt;BR /&gt;auth=""&lt;BR /&gt;subj=""&lt;BR /&gt;ema1=""&lt;BR /&gt;ema2=""&lt;BR /&gt;crazy=`cat $i | head -5 | tail -2`&lt;BR /&gt;auth=`echo $crazy|cut -d" " -f1`&lt;BR /&gt;subj=`echo $crazy|cut -d" " -f2-`&lt;BR /&gt;ema1=`echo $auth|cut -s -d"@" -f1`&lt;BR /&gt;ema2=`echo $auth|cut -s -d"@" -f2`&lt;BR /&gt;if [ "$ema1" -a "$ema2" ]; then&lt;BR /&gt;echo "Thank you for replying" | mailx -s "re: \"${subj}\"" $auth&lt;BR /&gt;echo "--------------------------"&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
    <pubDate>Mon, 16 Dec 2002 21:27:04 GMT</pubDate>
    <dc:creator>harry d brown jr</dc:creator>
    <dc:date>2002-12-16T21:27:04Z</dc:date>
    <item>
      <title>cut, grep etc....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-grep-etc/m-p/2865242#M821360</link>
      <description>Hi guys,&lt;BR /&gt;&lt;BR /&gt;I'm really fu*ked up with grep an cut commands.  And I'm trying to do a script in which I need to use them... &lt;BR /&gt;&lt;BR /&gt;Here is the structure of the content of the file that I'm trying to read:&lt;BR /&gt;&lt;BR /&gt;&lt;BLANK line=""&gt;&lt;BR /&gt;*********** START ***********&lt;BR /&gt;&lt;BLANK line=""&gt;&lt;BR /&gt;theemails@areonthatline.com&lt;BR /&gt;The subject is on that line&lt;BR /&gt;&lt;BLANK line=""&gt;&lt;BR /&gt;Multiple line of data&lt;BR /&gt;Multiple line of data&lt;BR /&gt;Multiple line of data&lt;BR /&gt;Multiple line of data&lt;BR /&gt;Multiple line of data&lt;BR /&gt;&lt;BLANK line=""&gt;&lt;BR /&gt;************ END ************&lt;BR /&gt;&lt;BLANK line=""&gt;&lt;BR /&gt;&lt;BR /&gt;What I need to do, is to send mail a the emails that are listed on the "real first" line and that subject on the other line. And then the rest of the file I'm gonna put it in the body of the email.  What I wanna you guys tell me is how can I extract the emails line, the subject line and the rest of my text file.  I just need to put the extraction in variables with them after I'm gonna use my script to send mail with a body... Please just told me how can I use grep or cut to get the info I need!!!&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;Jonathan&lt;BR /&gt;&lt;/BLANK&gt;&lt;/BLANK&gt;&lt;/BLANK&gt;&lt;/BLANK&gt;&lt;/BLANK&gt;</description>
      <pubDate>Mon, 16 Dec 2002 19:21:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-grep-etc/m-p/2865242#M821360</guid>
      <dc:creator>Jonathan Caplette_1</dc:creator>
      <dc:date>2002-12-16T19:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: cut, grep etc....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-grep-etc/m-p/2865243#M821361</link>
      <description>grep and cut may be a bit to crude to use for the purpose that you have stated.  Sed and awk might be more appropriate since the level of granularity you can get with sed and awk is much finer than with grep and/or cut.&lt;BR /&gt;&lt;BR /&gt;however, if grep and cut hav you throughly confused, sed and awk will make your head spin as they are cryptic, but powerful.</description>
      <pubDate>Mon, 16 Dec 2002 19:27:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-grep-etc/m-p/2865243#M821361</guid>
      <dc:creator>Vince Inman</dc:creator>
      <dc:date>2002-12-16T19:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: cut, grep etc....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-grep-etc/m-p/2865244#M821362</link>
      <description>First, help may be more available without the implied bad word ;)&lt;BR /&gt;&lt;BR /&gt;For your problem, it looks like you have a fixed format at least at the top of your data, which is good.&lt;BR /&gt;&lt;BR /&gt;4th line is subject&lt;BR /&gt;3rd line is the email addresses&lt;BR /&gt;&lt;BR /&gt;Lets call your file INFILE.  Subject is the easiest to extract, so here it is...&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;SUBJECT=`head -4 $INFILE|tail -1`&lt;BR /&gt;&lt;BR /&gt;Getting the email addresses will require a loop.  We can use head and tail to pull the 3rd line from the file to make a loop.  A blank space will be treated as a separator.&lt;BR /&gt;&lt;BR /&gt;for ADDRESS in `head -3 $INFILE|tail -1` ; do&lt;BR /&gt;&lt;BR /&gt;mailx $ADDRESS -s $SUBJECT $INFILE&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Assuming that you want the whole INFILE mailed, the above will work just fine.  If you dont want the subject and addresses from the file mailed, you will have to be a bit more creative with the script.&lt;BR /&gt;&lt;BR /&gt;If this is the case, I'd recommend making a temp file with the data you do want to mail, then wc to count lines, expr to remove calculate lines -4(remove header), then tail to build your temp file.&lt;BR /&gt;&lt;BR /&gt;Hope it helps, and no vast knowledge of grep or cut required for this job.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Shannon&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 16 Dec 2002 19:36:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-grep-etc/m-p/2865244#M821362</guid>
      <dc:creator>Shannon Petry</dc:creator>
      <dc:date>2002-12-16T19:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: cut, grep etc....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-grep-etc/m-p/2865245#M821363</link>
      <description>&lt;BR /&gt;Well said Shannon&lt;BR /&gt;&lt;BR /&gt;Jonathan please take notice.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Paula&lt;BR /&gt;</description>
      <pubDate>Mon, 16 Dec 2002 19:41:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-grep-etc/m-p/2865245#M821363</guid>
      <dc:creator>Paula J Frazer-Campbell</dc:creator>
      <dc:date>2002-12-16T19:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: cut, grep etc....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-grep-etc/m-p/2865246#M821364</link>
      <description>Thanks Shannon!!! Why I didn't think about using head and tail... lol!!!&lt;BR /&gt;&lt;BR /&gt;Sorry for the "F" word.... I'll watch it in the future!!!</description>
      <pubDate>Mon, 16 Dec 2002 19:44:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-grep-etc/m-p/2865246#M821364</guid>
      <dc:creator>Jonathan Caplette_1</dc:creator>
      <dc:date>2002-12-16T19:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: cut, grep etc....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-grep-etc/m-p/2865247#M821365</link>
      <description>&lt;BR /&gt;Where /tmp/ooo is your INPUT file:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;cd /tmp&lt;BR /&gt;rm abcd*&lt;BR /&gt;csplit -s -f abcd -n 4 /tmp/ooo '/^\*\*\*\*\*\*\*\*\*\*\*\* END \*\*\*\*\*\*\*\*&lt;BR /&gt;\*\*\*\*$/+1' {*}&lt;BR /&gt;for i in `ls abcd*`&lt;BR /&gt;do&lt;BR /&gt;crazy=""&lt;BR /&gt;auth=""&lt;BR /&gt;subj=""&lt;BR /&gt;ema1=""&lt;BR /&gt;ema2=""&lt;BR /&gt;crazy=`cat $i | head -5 | tail -2`&lt;BR /&gt;auth=`echo $crazy|cut -d" " -f1`&lt;BR /&gt;subj=`echo $crazy|cut -d" " -f2-`&lt;BR /&gt;ema1=`echo $auth|cut -s -d"@" -f1`&lt;BR /&gt;ema2=`echo $auth|cut -s -d"@" -f2`&lt;BR /&gt;if [ "$ema1" -a "$ema2" ]; then&lt;BR /&gt;echo "Thank you for replying" | mailx -s "re: \"${subj}\"" $auth&lt;BR /&gt;echo "--------------------------"&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Mon, 16 Dec 2002 21:27:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-grep-etc/m-p/2865247#M821365</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-12-16T21:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: cut, grep etc....</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/cut-grep-etc/m-p/2865248#M821366</link>
      <description>Jonathan:&lt;BR /&gt;&lt;BR /&gt;You have some good replies already but I still wanted to put in my two cents.  If I am understanding this correctly all you need is 'sed'. The 'sed' command will print any number of lines in a file.&lt;BR /&gt;If you have a number of files to parse through then using a loop would be good. So try this:&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;&lt;BR /&gt;for infile in &lt;FILE list=""&gt;&lt;BR /&gt;do&lt;BR /&gt;    inaddr="`sed -n '3p' ${infile}`"&lt;BR /&gt;    insubj="`sed -n '4p' ${infile}&lt;BR /&gt;    sed -n '6,$p' ${infile} | mailx -x${insubj} ${inaddr}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;I was not sure on the exact line numbers so just change the 3, 4, and 6 to whatever you need them to be.&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;&lt;BR /&gt;Thomas&lt;/FILE&gt;</description>
      <pubDate>Tue, 17 Dec 2002 14:26:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/cut-grep-etc/m-p/2865248#M821366</guid>
      <dc:creator>Thomas M. Williams_1</dc:creator>
      <dc:date>2002-12-17T14:26:06Z</dc:date>
    </item>
  </channel>
</rss>

