It is currently Tue, 17 May 2022 02:07:03 GMT



 
Author Message
 extracting text in bourne shell
Hi there,

I want to write a script that exract text from data file i.e

% cat data

########
data 1 1002
EC
########
data 2 2345
data 3 Error
EC
########
data 4 Error
data 5 254225
data 6 336586
data 7 578641
EC
########

now I want to extract the data b/w ##### i.e.

% extract data
data 1
EC
data 2
data3
EC
.
.
.
data 7

someone told me that I can use awk for this purpose but I don't know
how to prgramme in awk, so if suggesting me the solution in awk please
tell me also where can I get a good tutorial on (except for man
command bcoz it is very difficult to understand without examples).

Thank you all



 Sat, 14 Jan 2006 04:46:21 GMT   
 extracting text in bourne shell

perl -ne's/^#+$//;/\S/&&print' data

John
--
use Perl;
program
fulfillment



 Sat, 14 Jan 2006 06:39:06 GMT   
 extracting text in bourne shell
In article <5f5518d0.0307281246.e0b7...@posting.google.com>,

awk '/^#/ {next} {$3="";print}' infile

got to the gnu site and read about gawk

Chuck Demas

--
  Eat Healthy        |   _ _   | Nothing would be done at all,
  Stay Fit           |   @ @   | If a man waited to do it so well,
  Die Anyway         |    v    | That no one could find fault with it.
  de...@theworld.com |  \___/  | http://world.std.com/~cpd



 Sat, 14 Jan 2006 06:42:29 GMT   
 extracting text in bourne shell
Thank you for reply
I cannot use perl for this purpose.


 Sat, 14 Jan 2006 11:27:09 GMT   
 extracting text in bourne shell

"MIA" <sfr...@hotmail.com> a crit dans le message de news:
5f5518d0.0307281246.e0b7...@posting.google.com...

In shell, using cut and grep:

  grep -v '#' data | cut -f 1-2 -d\

In sed

  sed '/#/d;s/ /#/2;s/#.*//' data

Laurent



 Sat, 14 Jan 2006 13:47:12 GMT   
 extracting text in bourne shell

--
  "MIA" <sfr...@hotmail.com> wrote in message
news:5f5518d0.0307281246.e0b70da@posting.google.com...

Go to :
Effective AWK Programming : A User's Guide for GNU Awk
http://www.lns.cornell.edu/public/COMP/info/gawk/gawk_toc.html

--
Onismus Radebe



 Sat, 14 Jan 2006 19:01:56 GMT   
 extracting text in bourne shell

--
  "MIA" <sfr...@hotmail.com> wrote in message
news:5f5518d0.0307281246.e0b70da@posting.google.com...

Go to :
Effective AWK Programming : A User's Guide for GNU Awk
http://www.lns.cornell.edu/public/COMP/info/gawk/gawk_toc.html

--
Onismus Radebe



 Sat, 14 Jan 2006 19:01:56 GMT   
 extracting text in bourne shell
On 28 Jul 2003 13:46:21 -0700, MIA

For this task you could simply use:
grep -v '^#' data

--
Lazlo's Chinese Relativity Axiom:
        No matter how great your triumphs or how tragic your defeats --
        approximately one billion Chinese couldn't care less.



 Sat, 14 Jan 2006 09:40:35 GMT   
 
   [ 8 post ] 

Similar Threads

1. Self-extracting bourne shell script

2. extract extension in bourne shell

3. Light Speed Bourne Shell! (was: Bourne shell tricks)

4. Extracting text from a file in a shell script

5. Looping through a text file in bourne shell?

6. Translating variables in text file to their values using bourne shell

7. Basic Text-processing Questions for Bourne Shell

8. Script to extract portions of text from a text file

9. Extracting lines from a text file that match a certain criteria to another text file

10. Bourne Shell compatible shells (was: Request: which shells)


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software