Linked Questions

0
votes
1answer
135 views

Can i use & variable of sed for doing operation inside $()? [duplicate]

I am not sure whether the below statement can be done placing & inside $() so that each time & is replaced by 1,2,3,4 and 1 is added to it. echo 1 2 3 4 | tr ' ' '\n' | sed "s/.*/$(echo expr ...
8
votes
3answers
3k views

Addition of extremely large numbers in shell script

Suppose that two numbers are stored in two different files, a.txt and b.txt. Each number is large enough (more than 30 digits) to not be supported by the numeric data type used by bash. How may I ...
7
votes
3answers
2k views

Fastest way to sum Nth column in text file

I have a CSV file (in which the field separator is indeed comma) with 8 columns and a few million rows. Here's a sample: 1000024447,38111220,201705,181359,0,12,1,3090 1064458324,38009543,201507,9,0,1,...
5
votes
4answers
402 views

Summing rows in a new column using sed, awk and perl?

I have a file that contain numbers something like: 1 11 323 2 13 3 3 44 4 4 66 23 5 70 23 6 34 23 7 24 22 8 27 5 How can I sum the rows and output the results in a column, so the results are as ...
3
votes
5answers
990 views

arithmetic operations within column with awk or sed

I have a file whose columns contain simple arithmetic equations that I would like to merge to the arithmetic result. Input sample (tab-separated columns): +104-1+12 6 +3 I would like to ...
3
votes
2answers
1k views

Sed incremental arithmetic

I want to replace a number at the end of a string by incrementing the number by one each time I run a specific sed line. the string looks like this: server-port=25555 I was thinking I could run ...
1
vote
2answers
772 views

what's the simplest way to increment the numbers in this string 01:02:99 in unix?

What is the simplest way to increment the numbers in this string 01:02:99? Expected output: 01:03:00 I'm hoping for a sed response, but I don't think it would be simple.
2
votes
2answers
681 views

Sum of columns for rows containing a specific term

I'm wondering if there is any sed or awk command that can sum all columns for the rows with an identical identifier. For example, my file data.txt is set out as below, except that it contains ~1800 ...
0
votes
3answers
478 views

move the the specified String to specific position using sed

How to move the the specified string (starting with math) to specific position(20th column) using sed (with regex). Want to move the string starting with math to column 20 in every line and math ...
0
votes
3answers
58 views

I'd like to use one of three commands sed (number ranges)

There is one text file.(test.txt) 1970-01-01 1971-01-01 1972-01-01 1973-01-01 1974-01-01 .... 1993-01-01 1994-01-01 1995-01-01 1996-01-01 ... 2015-01-01 2016-01-01 I would like to clear the line of ...
1
vote
2answers
68 views

Replacing number with the same value (number) of one characters

I have to find all file types using file -b $(find . -type f), sort them into unique categories, and print out top 4 most categories where the number is replaced with equal number of "#". The output ...