Questions tagged [numeric-data]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
3answers
37 views

Find the maximum value of Column3 and print the values of Column1 and 2 only

In Unix, I am trying to find a command that would find the maximum value in Column3 and print the corresponding values from Column2 and Column1 (but not from Column3) in a new file. Column1 ...
1
vote
0answers
36 views

Read Data from raw devices [closed]

I have inserted a record on the table and I am trying to read the data using "STRINGS" command SQL> insert into DATA values (7299974551,'HARIHARAN',4544676688992251); 1 row created. I am able ...
0
votes
1answer
14 views

re-write column's values to obtain previous line's value if exceed number 1

I have a file containing the following list of numbers: 0.1131492 0.1231466 0.1327564 0.1017683 5.4356130 0.1360532 5.4258129 0.1433982 0.1124752 . . . I would like to re-write this list of numbers ...
0
votes
1answer
27 views

Sort file by row and with scientific numbers

I have a file F.tsv with 13 columns, the last column (the 13th columns) looks like this: 2.1e-06 0.58 10 8.7e-22 0.0014 0.034 9.5 0.67 0.67 0.68 9.2 8.4e-22 9.7 I've tried sort -k 13 F.tsv but it ...
1
vote
4answers
231 views

Sum of even and odd numbers of odd and even lines

I would like to write a shell script program that gives the sum of even and odd numbers in a given file's odd and even lines. I would like to use: sed -n 2~2p and sed -n 1~2p but I am not even ...
0
votes
1answer
54 views

Compare two lines using second columns

http://0-0.latam.corp.yahoo.com/ 6656 http://0-0.latam.corp.yahoo.com/nonEtAk 6670 http://1.avatar.yahoo.com/ ...
0
votes
3answers
50 views

how to read file line by line and delete the line have number less than 20% shell scripting

i need help. i have this file i want read it line by line with for loops and delete the line less than 20% the number will with list %CPU . %CPU PID USER UID COMMAND %MEM 71 9136 ...
2
votes
3answers
88 views

Generates random numbers with 11 digits

I need a command that generates random numbers with 11 digits. How can this be done?
4
votes
4answers
339 views

How can I adjust nth number in a line?

File contents: RANDOM TEXT num1=400 num2=15 RANDOM TEXT RANDOM TEXT num1=300 num2=10 RANDOM TEXT RANDOM TEXT num1=200 num2=5 RANDOM TEXT I would like to subtract 5 for ...
0
votes
1answer
33 views

How to add an average at then end of a table of values

I've been teaching myself Linux for 3 months now and I'm using the grep command but I also want an average of all of my extracted values. Command: grep -o "201[1-4].[0-9][ -9]" file1.txt file2.txt ...
6
votes
2answers
199 views

AWK if number less than previous number, how to add previous number to current number, and from then on

Have a field with distance data from GoPro. Need to concat the files together but the distance starts at 0 on each new csv file as video files are of only a set duration. So how would it be possible ...
0
votes
2answers
91 views

How to calculate max and min for each unique entry

I need to find the max and min of each entry in my file: #subset of my file NEUTRON 20.900103 PION- 0.215176 PION- 22.716532 NEUTRON 8.043279 PION+ 1.374297 PION- 0.313350 ...
0
votes
1answer
38 views

awk rounding error using int() in connection with log()

For later formatting I need to calculate the logarithm, base 10. Fine so far: $ awk 'BEGIN { print log(1000) / log(10) }' 3 $ awk 'BEGIN { print log(1001) / log(10) }' 3.00043 I need to kick the ...
13
votes
4answers
2k views

How to increment the value of a (decimal) variable (with leading zero) by +1?

I have a file in the name of Build.number with the content value 012 which I need to increment by +1. So, I tried this BN=$($cat Build.number) BN=$(($BN+1)) echo $BN >Build.number but here I am ...
1
vote
2answers
38 views

Replace single field numbers with double field numbers (1->01)

beginning with male 9 male 11 male 9 male 1 female 4 female 13 male 14 sort -u -k1,1 -k2,2n returns female 13 female 4 male 1 male 11 male 14 male 9 male 9 how can I make these numbers show as ...
0
votes
2answers
37 views

Highest Columns Number Records Issue

Highest Columns Number Records Issue I have a test.txt file with contents as follows: 1:2:3 123:5 34589:5:0 34567:8:7 781:9:09 Could you please help me getting the following output from that test....
0
votes
1answer
25 views

add multiple rows for a range of variable and condtional column to a file

I have a file with 4 columns. First two columns are for x and y position (in integers) and third, fourth column for an arbitrary field value. 1 1 0.5 1.2 1 2 1.7 2.3 1 3 2.0 2.2 2 1 1.4 2.5 2 2 1.6 ...
1
vote
2answers
73 views

get count with grep

im working on sun10 Solaris os,i have a process that returns table as by using this command dmh -q 12 the below: *PROFILE PRIORITY COMM_TYPE QID # OF MSGS ATTRIBUTES/VALUES* 13 ...
-3
votes
1answer
29 views

Adding a sequence of one hundred numbers to a starting number

If I have file like this: 1 19 24 119 201 230 ... then I want output like this: 1 2 3 4 .........100 19 20 21 22 .......119 24 25 26 ...........124 119 120 121 .......219 201 ...
0
votes
3answers
69 views

multiply specific column in a file which consists of thousands columns

The in file looks like this -17.3644 0.00000000 0.00000000 .... -17.2703 0.00000000 0.00000000 .... -17.1761 0.00000000 0.00000000 .... -16.5173 0.00000000 0....
4
votes
3answers
545 views

Print all lines that don't have numbers, using sed

I need to print all the lines containing non numeric characters using regex in sed. The input is a csv, and some of it's lines has text and numbers. I'm interested in printing only those without ...
-6
votes
2answers
92 views

How to check if integer value is less or more then 3

We have two values $a $b we need to compare the $a value with $b value in case $b value is less than ($a - 3) or more than ($a + 3), then it will print fail. example: a=10 b=14 then it should ...
0
votes
3answers
153 views

Replace and increment a line in bash

How can I read, increment and replace a value in a file? foo="val" ver="1.2.0001" ... Now I would like to increment the "0001" to 0002".
0
votes
2answers
51 views

How to always print an output with certain number of digits using AWK

I have the following command: find . -mtime -5 -type f -exec ls -ltr {} \; | awk '{print "cp -p "$9" "$7}' the output is like: cp -p ./18587_96xxdata.txt 10 cp -p ./16947_96xxdata.txt 8 cp -p ./...
0
votes
2answers
46 views

How to grep a string with any two numbers that match or that have the first number one less than the second number?

I have a tab delimited file with four columns. I would like to grep for the lines that have a specific pattern in column 1, where it says apple M of N.  I only want to extract the lines that have the ...
2
votes
3answers
111 views

bash: How to efficiently find root nodes given set of parent-child

I have a huge (few GBs) file of parent-ID, child-ID pairs. I also have an (incomplete) set of known root nodes. For each of the known child nodes I need to find a root node, i.e. the one either not ...
3
votes
2answers
181 views

Add leading zeroes to a user's input but is being transformed with printf

I am currently looking for an alternative to the following code that works a little less 'wonky'. printf "Please enter the ticket number:\t"; read vTICKET; vTICKET=$(printf %04d "$vTICKET"); printf "$...
0
votes
6answers
98 views

Keep only a few digits of decimal part

I have a file whose contents look like this. 2,0,-1.8433679676403103,0.001474487996447893 3,1,0.873903837905657,0.6927701848899038 1,1,-1.700947426133768,1.5546514434152598 CSV with four columns ...
-1
votes
4answers
1k views

How to represent greater than or equal 3600 in regex

I wrote this regex to match numbers greater than or equal 3600. This is my attempt. However, I am not sure if it is complete: grep -P '36[0-9]+[0-9]+[0-9]*' test.txt I mean positive decimal integer ...
6
votes
3answers
552 views

Trim trailing zeroes off a number extracted by jq

The following command achieve my goal by grepping BTC price from specific exchange. curl -sS https://api.binance.com/api/v1/ticker/price?symbol=BTCUSDT | jq -r '.price' the output will be for the ...
1
vote
1answer
802 views

How to sort the second column in descending order? [duplicate]

I want to sort my input file on the basis of the 2nd column in descending order. I have used the following command for this: sort -k2,2nr input.txt > output.txt However, after running the command ...
3
votes
4answers
699 views

How to grep and cut numbers from a file and sum them

I have a log file. For every line with a specific number, I want to sum the last number of those lines. To grep and cut is no problem but I don't know how to sum the numbers. I tried some solutions ...
0
votes
2answers
88 views

Add two doubles on bash

I'm trying to add two doubles y1=0.17580197E-01 y2=0.11979236E-02 sum=`echo $y1+$y2 | bc -l` the above script gives me sum = -2.704405652. How do i resolve this issue?
1
vote
0answers
24 views

bc command unexpected results [duplicate]

I am trying to compare a decimal and it seems like bc is ignoring it. The OS is CentOS release 6.9 (Final) and bash is bash-4.1.2-48.el6.x86_64, below is the code #!/bin/sh i=32.39 IP_LOW_2=32.0 ...
-1
votes
3answers
156 views

What does the following number-processing sed code mean?

I came across a code in script which add ',' after every 3 digits from backwards. the code only considers numeric data. Following is the code. sed 's/\(^\|[^0-9.]\)\([0-9]\+\)\([0-9]\{3\}\)/\1\2,\3/...
3
votes
2answers
363 views

How to obtain only positive value in second column [closed]

I use this command awk 'NR%2{t=$1;next}{print $1-t,$2}' to get the distance between two consecutive Y points in a file. But I would like to have all positive numbers. How to get that ? like ...
-1
votes
1answer
22 views

find in a file where sign of a column entry changes and print first line where this happens

I have multiply files, each with three columns. I would like to monitor where a given column entries first change sign (i.e negative to positive) so that I save that row where this first happens to ...
1
vote
2answers
105 views

How to sort comma-thousand separated numbers while on other locale

I have a German locale and need to sort US formatted numbers with commas as the thousands separator. Seems I don't override the locale properly? sort --version sort (GNU coreutils) 8.30 Example: ...
7
votes
2answers
999 views

How to read string as hex number in bash?

I have the bash line: expr substr $SUPERBLOCK 64 8 Which is return to me string line: 00080000 I know that this is, actually, a 0x00080000 in little-endian. Is there a way to create integer-...
6
votes
1answer
453 views

“sort -g” does not work as expected on data in scientific notation

I am trying to sort a data file in descending order. The data file is given by three columns delimited by tabs; I want to order them in descending order for the third column with (the third column is ...
2
votes
2answers
1k views

String to integer in Shell

I'm currently working on a project called 'dmCLI' which means 'download manager command line interface'. I'm using curl to multi-part download a file. And I'm having trouble with my code. I can't ...
2
votes
1answer
31 views

How to reflect data points across their median line?

Sample Input file name 0.00 -1.0000 number1 0.00 -0.8000 number2 0.00 -0.6000 number3 0.00 -0.4000 number4 0.00 -0.2000 number5 0.00 0.0000 number6 0.00 0.2000 number7 0....
0
votes
2answers
61 views

When I add 0 to 0.0, how do I make sure the result is 0.0 not 0?

There are two columns of numbers in a file, the first line like this: 0 0.0 I want to add the numbers in column 1 to those in column 2, and I want to keep the results floats, not ...
1
vote
2answers
50 views

Search specific numbers

im a list numbers in file and i would search 1 specific number in string Es. 1 54 67 78 32 11 4 67 89 90 13 67 87 32 21 My search is 1 With awk or grep commands out this numbers 1 11 13 ...
0
votes
2answers
59 views

If I have a number in a shell script, how would i access just one digit of that number? [closed]

I want to be able to go through and access each digit individually in a shell script. How would I do this?
5
votes
1answer
121 views

Why does gawk treat `0123` as a decimal number when coming from the input data?

According to $ man gawk, the strtonum() function can convert a string into a number: strtonum(str) Examine str, and return its numeric value. If str begins ...
0
votes
4answers
80 views

Find the largest positive number in my given data?

Can someone show me a way to find the largest positive number using awk,sed or some sort of unix shell program? I'm using Linux RHEL with KSH. The input may have 8 columns worth of data with N/A as ...
2
votes
6answers
816 views

count how many times each number occurs

A file contains 5 columns with numbers Example: 12 34 67 88 10 4 90 12 10 7 33 12 5 76 34 I would like to print the same number and see how many times it goes out. Example: 3 : 12 2 : 34
6
votes
6answers
2k views

How do I add numbers from two txt files with Bash?

I have a txt file that contains some numbers like this: 1 2 3 4 5 And I have another txt file that contains the same number of lines, but with other numbers: 6 7 8 9 10 I want ...
1
vote
0answers
46 views

Compute median over windows and groups

I have a file that looks like this: chr pos value A 1 23 A 2 32 ... A 200 32 ... B 1 41 B 2 28 ... The file is sorted by chr and pos. The ... is just to show the lots of rows in ...