Sponsored Content
Full Discussion: Adding number in one column
Top Forums Shell Programming and Scripting Adding number in one column Post 302968974 by MadeInGermany on Wednesday 16th of March 2016 03:44:59 PM
Old 03-16-2016
Quote:
Originally Posted by rdrtx1
try:
Code:
for i in {2..100}
do
   rm -f $i.dat
   while read a b
   do
      b=$(( b + i - 1 ))
      echo $a $b >> $i.dat
   done < 1.dat
done

Like you did with the input, you can redirect the output
Code:
for i in {2..100}
do
   while read a b
   do
      b=$(( b + i - 1 ))
      echo "$a $b"
   done < 1.dat > $i.dat
done

This is far more efficient than each time open-append-close.
(The csh does not have this capability.)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding a columnfrom a specifit line number to a specific line number

Hi, I have a huge file & I want to add a specific text in column. But I want to add this text from a specific line number to a specific line number & another text in to another range of line numbers. To be more specific: lets say my file has 1000 lines & 4 Columns. I want to add text "Hello"... (2 Replies)
Discussion started by: Ezy
2 Replies

2. UNIX for Dummies Questions & Answers

Adding a column with the row number using awk

Is there anyway to use awk to add a first column to my data that automatically goes from 1 to n , where n is the numbers of my rows?:confused: (4 Replies)
Discussion started by: cosmologist
4 Replies

3. Shell Programming and Scripting

Rename a header column by adding another column entry to the header column name URGENT!!

Hi All, I have a file example.csv which looks like this GrpID,TargetID,Signal,Avg_Num CSCH74_1_1,2007,61,256 CSCH74_1_1,212007,647,679 CSCH74_1_1,12007,3,32 CSCH74_1_1,207,299,777 I want the output as GrpID,TragetID,Signal-CSCH74_1_1,Avg_Num CSCH74_1_1,2007,61,256... (4 Replies)
Discussion started by: Vavad
4 Replies

4. UNIX for Dummies Questions & Answers

Rename a header column by adding another column entry to the header column name

Hi All, I have a file example.csv which looks like this GrpID,TargetID,Signal,Avg_Num CSCH74_1_1,2007,61,256 CSCH74_1_1,212007,647,679 CSCH74_1_1,12007,3,32 CSCH74_1_1,207,299,777 I want the output as GrpID,TragetID,Signal-CSCH74_1_1,Avg_Num CSCH74_1_1,2007,61,256... (1 Reply)
Discussion started by: Vavad
1 Replies

5. Shell Programming and Scripting

Taking largest (negative) number from column of coordinates and adding positive form to every other

Hello all, I'm new to the forums and hope to be able to contribute something useful in the future; however I must admit that what has prompted me to join is the fact that currently I need help with something that has me at the end of my tether. I have a PDB (Protein Data Bank) file which I... (13 Replies)
Discussion started by: crunchgargoyle
13 Replies

6. Shell Programming and Scripting

Adding a new column as sequential number but with a little complication

I am a newbie to shell programming and maybe somebody can help me out a little. Here's my problem: I got a PIPE delimited file with header record. I need to add a new column name as RECORDKEY. I would like to use a counter to generate this new value for each record. I plan to do a while loop and... (4 Replies)
Discussion started by: johnhips
4 Replies

7. Shell Programming and Scripting

Adding values of a column based on another column

Hello, I have a data such as this: ENSGALG00000000189 329 G A 4 2 0 ENSGALG00000000189 518 T C 5 1 0 ENSGALG00000000189 1104 G A 5 1 0 ENSGALG00000000187 3687 G T 5 1 0 ENSGALG00000000187 4533 A T 4 2 0 ENSGALG00000000233 5811 T C 4 2 0 ENSGALG00000000233 5998 C A 5 1 0 I want to... (3 Replies)
Discussion started by: Homa
3 Replies

8. Shell Programming and Scripting

Help with compare two column and print out column with smallest number

Input file : 5 20 500 2 20 41 41 0 23 1 Desired output : 5 2 20 0 1 By comparing column 1 and 2 in each line, I hope can print out the column with smallest number. I did try the following code, but it don't look good :( (2 Replies)
Discussion started by: perl_beginner
2 Replies

9. Shell Programming and Scripting

Split column data if the table has n number of column's

please write a shell script Table -------------------------- 1 2 3 a b c 3 4 5 c d e 7 8 9 f g h Output should be like this --------------- 1 2 3 3 4 5 7 8 9 a b c c d e f g h (1 Reply)
Discussion started by: Priti2277
1 Replies

10. Shell Programming and Scripting

Split column data if the table has n number of column's with some record

Split column data if the table has n number of column's with some record then how to split n number of colmn's line by line with records Table --------- Col1 col2 col3 col4 ....................col20 1 2 3 4 .................... 20 a b c d .................... v ... (11 Replies)
Discussion started by: Priti2277
11 Replies
GETRUSAGE(3)								 1							      GETRUSAGE(3)

getrusage - Gets the current resource usages

SYNOPSIS
array getrusage ([int $who]) DESCRIPTION
This is an interface to getrusage(2). It gets data returned from the system call. PARAMETERS
o $who - If $who is 1, getrusage will be called with RUSAGE_CHILDREN. RETURN VALUES
Returns an associative array containing the data returned from the system call. All entries are accessible by using their documented field names. EXAMPLES
Example #1 getrusage(3) example <?php $dat = getrusage(); echo $dat["ru_nswap"]; // number of swaps echo $dat["ru_majflt"]; // number of page faults echo $dat["ru_utime.tv_sec"]; // user time used (seconds) echo $dat["ru_utime.tv_usec"]; // user time used (microseconds) ?> CHANGELOG
+--------+---------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------+ | 7.0.0 | | | | | | | This function is now supported on Windows. | | | | +--------+---------------------------------------------+ NOTES
Note On Windows getrusage(3) will only return the following members: o "ru_stime.tv_sec" o "ru_stime.tv_usec" o "ru_utime.tv_sec" o "ru_utime.tv_usec" o "ru_majflt" (only if $who is RUSAGE_SELF) o "ru_maxrss" (only if $who is RUSAGE_SELF) If getrusage(3) is called with $who set to 1 ( RUSAGE_CHILDREN), then resource usage for threads are collected (meaning that inter- nally the function is called with RUSAGE_THREAD). Note on BeOS 2000, only the following members are returned: o "ru_stime.tv_sec" o "ru_stime.tv_usec" o "ru_utime.tv_sec" o "ru_utime.tv_usec" SEE ALSO
Your system's man page on getrusage(2). PHP Documentation Group GETRUSAGE(3)
All times are GMT -4. The time now is 10:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy