Sponsored Content
Top Forums Shell Programming and Scripting How to strip non numerical data out of file? Post 302102087 by Juha on Monday 8th of January 2007 09:11:44 AM
Old 01-08-2007
How to strip non numerical data out of file?

Hi,

How can I remove all non numerical data from line, so I don't want to delete the line but to have only the numbers.

e.g.:
#########
123
aaa124
125bbb
126
127
#########

So I want all the leading and trailing non numerical stuff(letters/white space/tabs anything else except [0-9]) stripped.

So from above I would get:
#########
123
124
125
126
127
#########

Thanks a lot for your help!
//Juha
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to strip apostrophe from a file

I am trying to remove or replace various extraneous characters from a file so that subsequent processes work correctly. The characters that is giving me trouble is the apostrophe '. The command I 'm trying is sed 's/\'//g' ${IN_WRK_DIR}/file1 > ${IN_WRK_DIR}/file2 in a Korn script on HP... (8 Replies)
Discussion started by: aquimby
8 Replies

2. UNIX for Dummies Questions & Answers

How to strip the contants from a file

Hi, I have some EDI data which 830, 862 and 997. Here is the sample data: ISA~00~ ~00~ ~ZZ~F159B ~ZZ~U1CAD ~051215~184 3~U~00200~000011432~0~P~< GS~FA~TC11A~U1CAD~051215~1843~000011432~X~002002 ST~997~0001 AK1~SH~1168 AK2~856~11680001 AK5~A... (2 Replies)
Discussion started by: isingh786
2 Replies

3. Programming

Adding files of numerical data

Hi I was hoping that maybe someone could help me with a small piece of C code. I have a number of files, which are all of similar layout ie. three lines of text and 5-6 columns of numerical data. I need to add each of the elements of the second column in one file to their counterparts in the second... (17 Replies)
Discussion started by: Boucho
17 Replies

4. Shell Programming and Scripting

Reading Numerical Binary Data using KSH

Hi, I've searched and couldn't find anyone else with this problem. Is there anyway (preferably using ksh - but other script languages would do) that I can read in binary float data into a text file. The data (arrays from various stages of radar processing) comes in various formats, but mainly... (3 Replies)
Discussion started by: Jonny2Vests
3 Replies

5. Shell Programming and Scripting

script to sort a string of numerical data in set fields

So, I will be working with someone and basically we are trying to build a form that is submitted most likely via the web and the data is just a string of numbers. like: 19383882872201110929282821818182827349190102837364718191001932873711 Now, each number is part of a numerical value of... (4 Replies)
Discussion started by: tlarkin
4 Replies

6. Shell Programming and Scripting

strip csv file

Hi everyone, I hope someone can help me: i am trying to get some info from a csv file, after i awk the column i need , i made a selection and output it in a file. now i need to get a list from this file, but i stuck with some fields. basically i have a text file with next data: 3... (3 Replies)
Discussion started by: lostym
3 Replies

7. Shell Programming and Scripting

how to extract data from numbered files using linux in the numerical order-

Hi experts, I have a list of files containing forces as the only number as follows. Force1.txt Force2.txt Force3.txt Force4.txt Force5.txt . . . . . . . . . Force100.txt I want to put all the data(only a number ) in these forces files in the file with the same order like 1,2,3 ..100 .... (2 Replies)
Discussion started by: hamnsan
2 Replies

8. UNIX for Dummies Questions & Answers

Divide a numerical data column by a variable

Hello, I have two files, f1 and f2. f1 has 5 columns like so: a b c d 154 e f g h 365 ..... f2 has two columns, the first column contains the name of the above file and second column contains a constant which is to be used for division. e.g. file1 56 I want to divide the 5th... (2 Replies)
Discussion started by: Gussifinknottle
2 Replies
MINTEGRATE(1)							   User Commands						     MINTEGRATE(1)

NAME
mintegrate - evaluate average/sum/integral/derivative of 1-d numerical data SYNOPSIS
mintegrate [OPTION]... [FILE] DESCRIPTION
mintegrate is a program to compute averages, sums, integrals or derivatives of numerical 1-d data in situations where ultimate numerical precision is not needed. OPTIONS
-a compute mean value (arithmetic average) and standard deviation -c compute integral on closed x-data interval; In case that dx is not specified by the '-d' flag, the data are supposed to be from an irregular x-grid, and dx is computed separately for every x-interval. The integral is computed by the trapezoidal rule. -d <float> compute integral on open x-data interval with the specified dx; Can be used also in combination with '-D' and '-c'. -D compute difference btw. numbers or derivative of the y-data; In the default scenario where x- and y-data column are same, the dif- ference btw. the current and the previous data value will be output. In this case when '-d' is defined as 0, the x-data value will be print out in front of the calculated difference. If x-and the y-column are different and if the x-data resolution is not defined or it is !=0, then the derivative of the y-data is calculated. When the x-data resolution is constant, specify it explicitly by '-d' to achieve a higher numerical precision by a 'leapfrog' algorithm. -x <int> x-data column (default is 1). If 0, the x-range is an index; -y <int> y-data column, where y=f(x) (default is 1) -r x_0:x_1 x-data range to consider -s print out accumulated y_i sums: x_i versus accumulated f(x_i); In the case of a closed integral you have to specify also the x-data resolution dx (see '-d' above). -S compute the accumulated y_i-sums and add it to the output -p <str> print format of the result ("%.10g" is default) -t <str> output text in front of the result (invalid with '-s' or '-S'); A blank can be printed by using a double underscore character '__'. -T run a self-test that the program is working correctly -V print version number --version output version and license message --help|-H display help -h display short help (options summary) If none of the options '-a', '-D', '-d', or '-c' is used, then the sum of the provided data will be computed. Empty lines or lines starting with '#' are skipped. This program is perfectly suitable as a basic tool for initial data analysis and will meet the expected accuracy of a numerical solution for the most demanding computer users and professionals. Yet be aware that, although the computations are carried with double floating pre- cision, the computational techniques used for evaluating an integral or a standard deviation are analytically low-order approximations, and thus not intended to be used for numerical computations in engineering or mathematical sciences for cases where an ultimate numerical pre- cision is a must. For deeper understanding of the topic see http://en.wikipedia.org/wiki/Numerical_analysis. COPYRIGHT
Copyright (C) 1997, 2001, 2006-2007, 2009, 2011-2012 Dimitar Ivanov License: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. mintegrate 2.2.1 February 2012 MINTEGRATE(1)
All times are GMT -4. The time now is 12:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy