Oct 22, 2002 #1 cosmos77 Programmer Oct 17, 2002 21 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
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
Oct 22, 2002 1 #2 CaKiwi Programmer Apr 8, 2001 1,294 US 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 Upvote 0 Downvote
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
Oct 22, 2002 1 Thread starter #3 cosmos77 Programmer Oct 17, 2002 21 US 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 Upvote 0 Downvote
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
Oct 22, 2002 #4 CaKiwi Programmer Apr 8, 2001 1,294 US try { for (j=1;j<=NF;j++) { if ($j ~ /^[0-9]+$/) print $j } } CaKiwi Upvote 0 Downvote
Oct 22, 2002 #5 vgersh99 Programmer Jul 27, 2000 2,146 US what is the "number"? Are the following considered 'valid numbers'? -2 3.567 1,200.5 1.2e3 vlad +---------------------------+ |#include<disclaimer.h> | +---------------------------+ Upvote 0 Downvote
what is the "number"? Are the following considered 'valid numbers'? -2 3.567 1,200.5 1.2e3 vlad +---------------------------+ |#include<disclaimer.h> | +---------------------------+
Oct 22, 2002 Thread starter #6 cosmos77 Programmer Oct 17, 2002 21 US Vlad, Iam sorry . integers to be more precise. Thanks ajay Upvote 0 Downvote
Oct 22, 2002 Thread starter #7 cosmos77 Programmer Oct 17, 2002 21 US CaKiwi This is printing out alphanumeric records too. like w0987 i just needed integers to printed out. Thanks Ajay Upvote 0 Downvote
CaKiwi This is printing out alphanumeric records too. like w0987 i just needed integers to printed out. Thanks Ajay
Oct 22, 2002 #8 CaKiwi Programmer Apr 8, 2001 1,294 US It does not print out w0987 for me. Post the script you are using and a simple data file that fails. CaKiwi Upvote 0 Downvote
It does not print out w0987 for me. Post the script you are using and a simple data file that fails. CaKiwi
Oct 22, 2002 Thread starter #9 cosmos77 Programmer Oct 17, 2002 21 US Thanks a lot CaKiwi, It works fine. There was a slight mix up from my end. Thanks again Ajay Upvote 0 Downvote