Sponsored Content
Top Forums UNIX for Dummies Questions & Answers [Solved] awk solution to add sequential numbers based on a word Post 302829381 by Corona688 on Thursday 4th of July 2013 04:58:01 PM
Old 07-04-2013
Code:
awk 'NR==1 { $2=$2"\t"NEWcol" ; print ; next }
{ A[$2]++ ; $2=$2"\t"A[$2] } 1' inputfile

These 2 Users Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK solution to subtract multiple columns of numbers

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

AWK help to add up sequential values

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

How to fetch rows based on line numbers or based on the beginning of a word?

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

awk fetch numbers after the word

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

word frequency counter - awk solution?

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

Sequential numbers

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

[Solved] Add row of numbers

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

awk solution to duplicate lines based on column

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

Replace groups into sequential numbers

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

awk to adjust coordinates in field based on sequential numbers in another field

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
H5FROMH4(1)							      h5utils							       H5FROMH4(1)

NAME
h5fromh4 - convert HDF4 scientific datasets to an HDF5 file SYNOPSIS
h5fromh4 [OPTION]... [HDF4FILE]... DESCRIPTION
h5fromh4 takes one or more files in HDF4 format and outputs files in HDF5 format containing the datasets from the HDF4 files. (Currently, only a single dataset per HDF4 file is converted.) HDF4 and HDF5 are free, portable binary formats and supporting libraries developed by the National Center for Supercomputing Applications at the University of Illinois in Urbana-Champaign. A single h5 file can contain multiple data sets; by default, h5fromh4 creates a dataset called "data", but this can be changed via the -d option, or by using the syntax HDF5FILE:DATASET with the -o option. The -a option can be used to append new datasets to an existing HDF5 file. If the -o option is used and multiple HDF4 files are specified, all the HDF4 datasets are output into that HDF5 file with the input filenames (minus the ".hdf" suffix) used as the dataset names. The most basic usage is something like 'h5fromh4 foo.hdf', which will output a file foo.h5 containing the scientific dataset from foo.hdf. OPTIONS
-h Display help on the command-line options and usage. -V Print the version number and copyright info for h5fromh4. -v Verbose output. -a If the HDF5 output file already exists, append the data as a new dataset rather than overwriting the file (the default behavior). An existing dataset of the same name within the file is overwritten, however. -o file Send HDF5 output to file rather than to the input filename with .hdf replaced with .h5 (the default). If multiple input files were specified, this causes all input datasets to be stored in file (rather than in separate files), with the input filenames (minus the .hdf suffix) as the dataset names. -d name Write to dataset name in the output; otherwise, the output dataset is called "data" by default. Alternatively, use the syntax HDF5FILE:DATASET with the -o option. BUGS
Send bug reports to S. G. Johnson, stevenj@alum.mit.edu. AUTHORS
Written by Steven G. Johnson. Copyright (c) 2005 by the Massachusetts Institute of Technology. h5utils March 9, 2002 H5FROMH4(1)
All times are GMT -4. The time now is 03:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy