How to check if the file contains only numeric values


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to check if the file contains only numeric values
# 1  
Old 08-17-2009
How to check if the file contains only numeric values

How to check if the file contains only numeric values.

I don't want to read entire file it eats lot of cpu

Or any way which consumes less memory n cpu..

Please suggest

-S
# 2  
Old 08-17-2009
Code:
grep -cv '[0-9]' file

# 3  
Old 08-17-2009
Are there more than one value per line? Integers only? Plus/minus? Octal? Hex?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Replace a numeric values in a certain column

Hi All, I am trying to replace a certain value from one place in a file . In the below file at position 35 I will have 8 I need to modify all 8 in that position to 7 I tried awk '{gsub("8","7",$35)}1' infile > outfile ----> not working sed -i 's/8/7'g' infile --- it is replacing all... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies

2. Shell Programming and Scripting

Use AWK to check for numeric values? (BASH script)

Hi, I'm quite new to scripting, but know a few AWK statements. I have the following line in my script: hostname=`echo $file | awk 'BEGIN{FS=OFS="."}{$NF=""; NF--; print}'` I use this in my script to rename files, which are similar to this: name.mvkf.mkvfm.mkfvm.1 To the... (4 Replies)
Discussion started by: TauntaunHerder
4 Replies

3. Shell Programming and Scripting

How to check for a Numeric Value?

Using shell, I have a variable, how can I check that variable for a numeric value such as "41.0"? My program needs to do one things if the numeric value is found, and another if something else such as a string of letter is found. is there a specific character that denotes a numeral? The... (2 Replies)
Discussion started by: chagan02
2 Replies

4. Shell Programming and Scripting

Check values in file

Hi, I have a tab delimited file in which first row is the header and others rows has the values. A B C D 2 4 0.00 3.00 0.00 9.78 4654 898 I have to check whether all the values are zero. A B C D 0.00 0 0.00 0.00 0.00 0.00 0 0.000 Send mail if all the values in file are zero (4 Replies)
Discussion started by: sandy1028
4 Replies

5. Shell Programming and Scripting

how to grep only particular length of numeric values

hi i have two types of file 1. temp.0000000001.data (10 digit numeric) 2. temp.000000001.data (9 digit numeric) i want to search a file which is having 10 digit numeric in between the file name. i use command like this.. ls | grep temp.^*.data but this will give both the files as... (2 Replies)
Discussion started by: somi2yoga
2 Replies

6. Shell Programming and Scripting

How to check if a column is having a numeric value or not in a file?

Hi, I want to know, how we find out if a column is having a numeric value or not. For Example if we have a csv file as ASDF,QWER,GHJK,123,FGHY,9876 GHTY,NVHR,WOPI,623,HFBS,5386 we need to find out if the 4th and 6th column has muneric value or not. Thanks in advance Keerthan (9 Replies)
Discussion started by: keerthan
9 Replies

7. Shell Programming and Scripting

PERL:How to convert numeric values txt file to PACKED DECIMAL File?

Is there any way to convert numeric values txt file to PACKED DECIMAL File using PERL. Regards, Alok (1 Reply)
Discussion started by: aloktiwary
1 Replies

8. Programming

numeric values ending in 'U'

I am getting back on the C++ programming after many years away. I recently received an SDK that has code like this where numeric values end in 'U'. What does this mean? if ((ptr % 16U) == 0U) return buffer; (3 Replies)
Discussion started by: sneakyimp
3 Replies

9. Shell Programming and Scripting

stripping out non-numeric values in a list

hi all, i'm very new to scripting and have the folllowing issue. I have used a few commands to get a list of numbers, but I need to strip away the non-numeric ones, and then need a total of all values. any ideas? root@unixserver # cat myfile | awk '{print $8}'| sort -rn 1504 1344 896 704... (2 Replies)
Discussion started by: badoshi
2 Replies

10. Shell Programming and Scripting

Replace spaces with 0's having numeric values.

What could be the regular expression with gsub function in awk to replace all numerics having spaces before to be replaced with 0s? (1 Reply)
Discussion started by: videsh77
1 Replies
Login or Register to Ask a Question