07-08-2013
Quote:
Posted by Corona688
Code:
awk 'NR==1 { $2=$2"\t"NEWcol" ; print ; next }{ A[$2]++ ; $2=$2"\t"A[$2] } 1' inputfile
Thanks a lot Corona688 for this great command, could you please also let us know the concept behind same. Will be grateful to you.
Thanks,
R. Singh
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hope somebody is happy.
NR==1 {
num_columns=split( $0, menuend );
next;
}
{
split( $0, substrend );
for ( i=1; i<=NF; i++ ) {
minuend -= substrend;
}
}
END {
print "Result:";
for ( i=1; i<=num_columns; i++ ) {
printf(... (3 Replies)
Discussion started by: awkward
3 Replies
2. Shell Programming and Scripting
Hello All!
As a beginner user i want to add up sequential values in a text file and want to print total sum as output.The Text file will have values like the following:
class1{root}>less SUM.txt
1140.00 1155.00 1183.00 ... # it continues #
i tried to write a... (1 Reply)
Discussion started by: EAGL€
1 Replies
3. Shell Programming and Scripting
I have a file which will have rows like shown below,
ST*820*316054716
RMR*IV*11333331009*PO*40.31
REF*IV*22234441009*xsss471-2762
DTM*003*091016
ENT*000006
RMR*IV*2222234444*PO*239.91
REF*IV*1234445451009*LJhjlkhkj471-2762 </SPAN>
DTM*003*
091016
RMR*IV*2223344441009*PO*40.31... (18 Replies)
Discussion started by: Muthuraj K
18 Replies
4. Shell Programming and Scripting
Hi,
I would want to fetch all the numbers after a word the number of characters could very. how can I do that?
below is the example of the data and the expected output
sample data
03 xxxx occurs 1090 times.
04 aslkja occurs 10 times.
I would want to fetch 10 & 1090 separately. (13 Replies)
Discussion started by: ahmedwaseem2000
13 Replies
5. Shell Programming and Scripting
Dear all,
i need your help on this. There is a text file, i need to count word frequency for each word with frequency >40 in each line of file and output it into another file with columns like this:
word1,word2,word3, ...wordn
0,0,1
1,2,0
3,2,0 etc -- each raw represents... (13 Replies)
Discussion started by: irrevocabile
13 Replies
6. Shell Programming and Scripting
Hi All,
I am looking for a simple way to write numbers to a file sequentially starting from 1 and ending on a specified upper limit. Example of the output file is below
Example
1
2
3
4
5
.
.
.
.
1000
please let me know the best way to do it. (10 Replies)
Discussion started by: Lucky Ali
10 Replies
7. UNIX for Dummies Questions & Answers
Hi,
Trying to add a row of numbers. There are 24 number across. Would like to have column 25 sum each row.
10 3 45 49 0 24... Sum
3 200 3 9 1 3 ...... Sum
9 7 20 9 8 10 ...... Sum
Thank you. (5 Replies)
Discussion started by: jimmyf
5 Replies
8. UNIX for Dummies Questions & Answers
Hi experts, I have a tab-delimited file with one column containing values separated by a comma. I wish to duplicate the entire line for every value in that comma-delimited field.
For example:
$cat file
4444 4444 4444 4444
9990 2222,7777 6666 2222 ... (3 Replies)
Discussion started by: torchij
3 Replies
9. UNIX for Dummies Questions & Answers
I have a file that looks like this:
n1 1
n2 1
n3 1
n4 3
n4 3
n2 5
n2 5
n2 5
n2 5
n3 5
n3 5
n4 6
n7 6
that is a name followed be a descriptive number.
I want to make these numbers sequential starting from 0 but without changing the "neighbours" each name belongs to. So the above... (3 Replies)
Discussion started by: FelipeAd
3 Replies
10. Shell Programming and Scripting
I am trying to output a tab-delimited result that uses the data from a tab-delimited file to combine and subtract specific lines.
If $4 matches in each line then the first matching sequential $6 value is added to $2, unless the value is 1, then the original $2 is used (like in the case of line... (3 Replies)
Discussion started by: cmccabe
3 Replies
LEARN ABOUT SUSE
getdelays
GETDELAYS(1) General Commands Manual GETDELAYS(1)
NAME
getdelays -- Display delay statistics
SYNOPSIS
getdelays -c command
getdelays -p pid
getdelays -t tid
DESCRIPTION
The getdelays utility helps pin-point possible resource shortages when running an application. The SLES10 kernel includes patches to imple-
ment delay accounting, which measures the time a process spends waiting for disk I/O, swap I/O and CPU time slices. For example, if an
application is running rather slowly, delay accounting can tell you where it spends all its time.
For instance, when the CPU delay is high, this means the application is competing with other proces for run time, but is losing quite
often.
High memory delays mean that the sum of applications running on this system need more physical memory than is available, and are swapping
quite a lot.
In order to enable delay accounting, you need to specify delayacct on the kernel command line when booting the system.
Getdelays has three modes of operation:
getdelays -c command
This will invoke command and print a summary of delay statistics when the command finishes.
getdelays -p pid
This will print the current delay statistics of the process identified pid.
getdelays -t tid
This will print the current delay statistics of the thread group identified tid.
AUTHOR
Balbir Singh, IBM Corp.
Shailabh Nagar, IBM Corp.
Manpage contributed by Olaf Kirch <okir@suse.de>
April 13, 2006 GETDELAYS(1)