Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting a list of numbers in numerous files. 2

Status
Not open for further replies.

cosmos77

Programmer
Oct 17, 2002
21
0
0
US
Hi,
i have a lot (i.e around 10000) files with *.te extension.

i want to list out all the numbers in these files and print the numbers to another file.

is there an awk script that can take care of this.

Thanks in advance.
Ajay
 
If you just want to print any line with a number on it, try

awk '/[0-9]/' *.te > output-file

If this is not what you want, post an example of the input data and the output you expect. CaKiwi
 
Thanks CaKiwi for the tip .
But the thing is i just want to print out the number and not the entire line. here is a small sample.


i have a text file having records like

file1
------

t xf 56 amboy
fg 84 79 345
hj 97 4567

and i want to print out to file 2 like

file2
----
56
84
79
345
97
4567

which are the list of all the numbers.


Thanks
Ajay



 
try

{
for (j=1;j<=NF;j++) {
if ($j ~ /^[0-9]+$/) print $j
}
} CaKiwi
 
what is the &quot;number&quot;?
Are the following considered 'valid numbers'?

-2
3.567
1,200.5
1.2e3 vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Vlad,

Iam sorry .
integers to be more precise.

Thanks
ajay

 
CaKiwi
This is printing out alphanumeric records too. like w0987

i just needed integers to printed out.


Thanks
Ajay
 
It does not print out w0987 for me. Post the script you are using and a simple data file that fails. CaKiwi
 
Thanks a lot CaKiwi, It works fine. There was a slight mix up from my end.


Thanks again
Ajay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top