03-22-2010
Extracting formatted text and numbers
Hello,
I have a file of text and numbers from which I want to extract certain fields and write it to a new file. I would use awk but unfortunately the input data isn't always formatted into the correct columns. I am using tcsh.
For example, given the following data
Quote:
1964.01.17 121427.6 24.268s 177.074w 158.0km 4.8 Tonga 1
ep :aang= -18.5 90% : l=267.9,az= -18.5,pl=35.9
ellipse: a= 188.6 ellipsoid: l= 59.3,az= 158.6,pl=54.0
(90% ) : b= 25.2 semi-axis: l= 29.4,az=-109.5,pl= 1.4
1964.01.18 41437.6 30.000s 177.900w 48.0km 4.8 Tonga
I want to extract:
Quote:
1964.01.17, 24.268s, 177.074w, 158.0km, 4.8, aang = -18.5, a= 188.6, b= 25.2
and print it in one line of a new file as:
Quote:
1964.01.17 24.268 177.074 158.0 4.8 -18.5 188.6 25.2
and extract
Quote:
1964.01.18, 41437.6, 30.000s, 177.900w , 48.0km, 4.8
and print it as:
Quote:
1964.01.18 41437.6 30.000 177.900 48.0 4.8 0 0 0
Does anyone have any ideas as to what command I Should use?
Thanks,
Dan
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi guys, i need your help.
I need to convert a date like this one 20071003071023 , to a formated date
like 20071003 07:10:23 .
Could this be possible ?
Regards,
Osramos (6 Replies)
Discussion started by: osramos
6 Replies
2. Shell Programming and Scripting
Hi Everyone, I've been using this site as a great resource to aid me with simple search and replace tasks. I still consider myself a novice and now I've been pulling my hair out over this problem. Any hints or suggestions would be welcome!
I have a text file in a format like this
name:... (6 Replies)
Discussion started by: regexnub
6 Replies
3. Shell Programming and Scripting
Hello!!!
I am using shell script that print some formated text on the screen (example)
========
hello I am ...
========
Is it possible to print this information to the printer exactly as I see it on the screen??? (6 Replies)
Discussion started by: tdev457
6 Replies
4. UNIX for Dummies Questions & Answers
##### (0 Replies)
Discussion started by: lucasvs
0 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I am trying to extract lines from a text file given a text file containing line numbers to be extracted from the first file. How do I go about doing this? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies
6. Shell Programming and Scripting
Hello,
I have a file ff.txt that looks as follows
*ABNA.txt
356
24
36
112
*AC24.txt
457
458
321
2
ABNA.txt and AC24.txt are the files in the folder named foo1. Based on the numbers in the ff.txt file, I want to extract the lines from the corresponding files in the foo1 folder and... (2 Replies)
Discussion started by: mohamad
2 Replies
7. Shell Programming and Scripting
Hi I am part of a academic organization and I want to send a fax to the students however there must be a quicker way to get the fax numbers extracted from the online forms they sent me.
The file looks like this (numbers are fake in order to protect identity):
Biochemistry Major
Michael... (3 Replies)
Discussion started by: phil_heath
3 Replies
8. Shell Programming and Scripting
How to split the file and have suffix with formatted numbers
Tried the following code
awk '{filename="split."int((NR-1)/2)".txt"; print >> filename}' split.txt
Current Result
Expected Result (21 Replies)
Discussion started by: bobbygsk
21 Replies
9. Shell Programming and Scripting
Dear All,
I have to solve the following problems with multiple tab-separated text file but I don't know how. Any help would be greatly appreciated. I have access to Linux mint (but not as a professional).
I have multiple tab-delimited files with the following structure:
file1:
1 44
2 ... (5 Replies)
Discussion started by: Bastami
5 Replies
10. Shell Programming and Scripting
I need to sum up the values in field nr 5 in a data file that contains some file listing. The 5th field denotes the size of each file and following are some sample values.
1,775,947,633
4,738
7,300
16,610
15,279
0
0
I tried the following code in a shell script.
awk '{sum+=$5} END{print... (4 Replies)
Discussion started by: krishmaths
4 Replies
LEARN ABOUT ULTRIX
ppmtopgm
ppmtopgm(1) General Commands Manual ppmtopgm(1)
NAME
ppmtopgm - convert a portable pixmap into a portable graymap
SYNOPSIS
ppmtopgm [ppmfile]
DESCRIPTION
Reads a portable pixmap as input. Produces a portable graymap as output. The output is a "black and white" rendering of the original
image, as in a black and white photograph. The quantization formula used is .299 r + .587 g + .114 b.
Note that although there is a pgmtoppm program, it is not necessary for simple conversions from pgm to ppm , because any ppm program can
read pgm (and pbm ) files automatically. pgmtoppm is for colorizing a pgm file. Also, see ppmtorgb3 for a different way of converting
color to gray. And ppmdist generates a grayscale image from a color image, but in a way that makes it easy to differentiate the original
colors, not necessarily a way that looks like a black and white photograph.
QUOTE
Cold-hearted orb that rules the night
Removes the colors from our sight
Red is gray, and yellow white
But we decide which is right
And which is a quantization error.
SEE ALSO
pgmtoppm(1),ppmtorgb3(1),rgb3toppm(1),ppmdist(1),ppm(5),pgm(5)
AUTHOR
Copyright (C) 1989 by Jef Poskanzer.
10 April 2000 ppmtopgm(1)