Sponsored Content
Top Forums Shell Programming and Scripting Concatenate rows and redefine range Post 302945916 by alex2005 on Thursday 4th of June 2015 05:51:44 PM
Old 06-04-2015
Concatenate rows and redefine range

I'm trying to find a way to concatenate consecutive rows (key is column $1 and $2) if column $5 an $6 are integers and redefine ranges in columns $3&$4 and $5&$6

Unfortunately I'm still learning the very basics so I cannot figure a way of doing this with awk.

Input file

Code:
15 30  21  21  25.0  25.0
15 30  22  22  26.0  26.0
15 30  23  23  27.0  27.0
15 30  24  24  28.5  28.5
15 30  25  25  29.7  29.7
15 30  26  26  30.0  30.0
15 30  27  27  31.0  31.0
17 32 155 155 325.0 325.0
17 32 156 156 326.3 326.3
17 32 158 158 424.0 424.0
17 32 159 159 425.0 425.0
17 32 160 160 426.0 426.0


Desired output:

Code:
15 30  21  23  25.0  27.0
15 30  24  24  28.5  28.5
15 30  25  25  29.7  29.7
15 30  26  27  30.0  31.0 
17 32 155 155 325.0 325.0
17 32 156 156 326.3 326.3
17 32 158 160 424.0 426.0

Thanks in advance!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Concatenate 2 rows into 1 row

I need to search a file for two values (valueA & valueB). ValueA will be on a different row than valueB, and concatenate the two together on the same row of my output. Example: search input file for strings "node" and "OS", combine the two results into one row input node A text text OS... (4 Replies)
Discussion started by: indianadoug
4 Replies

2. Shell Programming and Scripting

Concatenate rows in to 2 files

I have 2 files FILEA 1232342 1232342 2344767 4576823 2325642 FILEB 3472328 2347248 1237123 1232344 8787890 I want the output to go into a 3rd file and look like: FILEC 1232342 3472328 (1 Reply)
Discussion started by: unxusr123
1 Replies

3. Shell Programming and Scripting

concatenate two files with different No of rows

need a shell which perform following function file 1 ( every time new data comes) 1212 2323 3434 4545 5656 . . . . file 2 (fixed line) update bc_tbl set aix=data , bix=back where cix=U and serial=; now when i execute shell it will concatinate file 1, file 2 & make file 3 as... (3 Replies)
Discussion started by: The_Archer
3 Replies

4. Shell Programming and Scripting

Concatenate some of the rows...

i have a file as below and i need to load it into oracle. The problem is, some of the rows are in 2 lines. 123456_PosWlist ----- ----- IN 0/0 123456_PosWListRpt ----- ----- IN 0/0 123456_PosWListCSV ----- -----... (7 Replies)
Discussion started by: Amit.Sagpariya
7 Replies

5. Shell Programming and Scripting

delete rows between closest pattern or range

Hi I am having some problom deleting the lines between two specific lines in a file. need to delete lines between two closest lines. i.e need to find the closest range or pattern in a file with repeating patterns. Sample Input: WARNING <some text in n number of lines> ERROR:2597... (10 Replies)
Discussion started by: sudheer1984
10 Replies

6. UNIX for Dummies Questions & Answers

Read rows from source file and concatenate output

Hi guys; TBH I am an absolute novice, when it comes to scripting; I do have an idea of the basic commands... Here is my problem; I have a flatfile 'A' containing a single column with multiple rows. I have to create a script which will use 'A' as input and then output a string in in the... (0 Replies)
Discussion started by: carlos_anubis
0 Replies

7. Shell Programming and Scripting

Need help to read rows from one file and concatenate to another

Hi guys; TBH I am an absolute novice, when it comes to scripting; I do have an idea of the basic commands... Here is my problem; I have a flatfile 'A' containing a single column with multiple rows. I have to create a script which will use 'A' as input and then output a string in in the... (6 Replies)
Discussion started by: carlos_anubis
6 Replies

8. Shell Programming and Scripting

Sum of range of rows and columns in matrix

Hi all, I have a large matrix of 720 x 25. I want to get sum of range of rows and columns. Like, I need sum of all columns and row number 2 to 21, then leaving 22nd row, again sum of all columns and row number 23 to 42 again leaving 43rd row and then sum of 44th to 63. Means I want to add all... (4 Replies)
Discussion started by: CAch
4 Replies

9. Shell Programming and Scripting

Printing rows based on column range

Hello, I have a file with nearly 57K lines. I want to filter the lines based on the range of values in a column. For e.g. print lines whose 3rd filed is >=0.02. Input file: LOC_Os09g32030 LOC_Os02g18880 0.0200037219149773 undirected NA NA LOC_Os03g58630 LOC_Os09g35690 ... (1 Reply)
Discussion started by: Sanchari
1 Replies

10. Shell Programming and Scripting

Concatenate broken rows

I need to concatenate the rows that are broken (because of carriage return and line feed) in unix. Input 123|456|789|"" 987|786|"GRT "|"" 3455|896|654|456|"" 457|234|"RT"|"PR TY"|"" Output 123|456|789|"" 987|786|"GRT"|"" 3455|896|654|456|"" 457|234|"RT"|"PRTY"|"" (16 Replies)
Discussion started by: meet_calramz
16 Replies
NODESET(1)						     ClusterShell User Manual							NODESET(1)

NAME
nodeset - compute advanced nodeset operations SYNOPSIS
nodeset [COMMAND] [OPTIONS] [nodeset1 [-ixX] nodeset2|...] DESCRIPTION
nodeset is an utility command provided with the ClusterShell library which implements some features of ClusterShell's NodeSet and RangeSet Python classes. It provides easy manipulation of indexed cluster nodes and node groups. It is automatically bound to the library node group resolution mechanism. Thus, nodeset is especially useful to enhance cluster aware administration shell scripts. OPTIONS
--version show program's version number and exit -h, --help show this help message and exit -s GROUPSOURCE, --groupsource=GROUPSOURCE optional groups.conf(5) group source to use Commands: -c, --count show number of nodes in nodeset(s) -e, --expand expand nodeset(s) to separate nodes (see also -S SEPARATOR) -f, --fold fold nodeset(s) (or separate nodes) into one nodeset -l, --list list node groups, list node groups and nodes (-ll) or list node groups, nodes and node count (-lll). When no argument is specified at all, this command will list all node group names found in selected group source (see also -s GROUPSOURCE). If any nodesets are specified as argument, this command will find node groups these nodes belongs to (individually). Option- ally for each group, the fraction of these nodes being member of the group may be displayed (with -ll), and also member count/total group node count (with -lll). If a single hyphen-minus (-) is given as a nodeset, it will be read from stan- dard input. -r, --regroup fold nodes using node groups (see -s GROUPSOURCE) --groupsources list all configured group sources (see groups.conf(5)) Operations: -x SUB_NODES, --exclude=SUB_NODES exclude specified nodeset -i AND_NODES, --intersection=AND_NODES calculate nodesets intersection -X XOR_NODES, --xor=XOR_NODES calculate symmetric difference between nodesets Options: -a, --all call external node groups support to display all nodes --autostep=AUTOSTEP auto step threshold number when folding nodesets, if not specified, auto step is disabled. Example: autostep=4, "node2 node4 node6" folds in node[2,4,6] but autostep=3, "node2 node4 node6" folds in node[2-6/2] -d, --debug output more messages for debugging purpose -q, --quiet be quiet, print essential output only -R, --rangeset switch to RangeSet instead of NodeSet. Useful when working on numerical cluster ranges, eg. 1,5,18-31 -G, --groupbase hide group source prefix (always @groupname) -S SEPARATOR, --separator=SEPARATOR separator string to use when expanding nodesets (default: ' ') -I SLICE_RANGESET, --slice=SLICE_RANGESET return sliced off result; examples of SLICE_RANGESET are "0" for simple index selection, or "1-9/2,16" for complex range- set selection --split=MAXSPLIT split result into a number of subsets --contiguous split result into contiguous subsets (ie. for nodeset, subsets will contain nodes with same pattern name and a contiguous range of indexes, like foobar[1-100]; for rangeset, subsets with consists in contiguous index ranges)""" For a short explanation of these options, see -h, --help. If a single hyphen-minus (-) is given as a nodeset, it will be read from standard input. EXTENDED PATTERNS
The nodeset command benefits from ClusterShell NodeSet basic arithmetic addition. This feature extends recognized string patterns by sup- porting operators matching all Operations seen previously. String patterns are read from left to right, by proceeding any character opera- tors accordinately. Supported character operators , indicates that the union of both left and right nodeset should be computed before continuing ! indicates the difference operation & indicates the intersection operation ^ indicates the symmetric difference (XOR) operation Care should be taken to escape these characters as needed when the shell does not interpret them literally. Examples of use of extended patterns $ nodeset -f node[0-7],node[8-10] node[0-10] $ nodeset -f node[0-10]!node[8-10] node[0-7] $ nodeset -f node[0-10]&node[5-13] node[5-10] $ nodeset -f node[0-10]^node[5-13] node[0-4,11-13] Example of advanced usage $ nodeset -f @gpu^@slurm:bigmem!@chassis[1-9/2] This computes a folded nodeset containing nodes found in group @gpu and @slurm:bigmem, but not in both, minus the nodes found in odd chassis groups from 1 to 9. EXIT STATUS
An exit status of zero indicates success of the nodeset command. A non-zero exit status indicates failure. EXAMPLES
Getting the node count $ nodeset -c node[0-7,32-159] 136 $ nodeset -c node[0-7,32-159] node[160-163] 140 $ nodeset -c @login 4 Folding nodesets $ nodeset -f node[0-7,32-159] node[160-163] node[0-7,32-163] $ echo node3 node6 node1 node2 node7 node5 | nodeset -f node[1-3,5-7] Expanding nodesets $ nodeset -e node[160-163] node160 node161 node162 node163 Excluding nodes from nodeset $ nodeset -f node[32-159] -x node33 node[32,34-159] Computing nodesets intersection $ nodeset -f node[32-159] -i node[0-7,20-21,32,156-159] node[32,156-159] Computing nodesets symmetric difference (xor) $ nodeset -f node[33-159] --xor node[32-33,156-159] node[32,34-155] Splitting nodes into several nodesets (expanding results) $ nodeset -e --split=3 node[1-9] node1 node2 node3 node4 node5 node6 node7 node8 node9 Splitting non-contiguous nodesets (folding results) $ nodeset -f --contiguous node2 node3 node4 node8 node9 node[2-4] node[8-9] HISTORY
Command syntax has been changed since nodeset command available with ClusterShell v1.1. Operations, like --intersection or -x, are now specified between nodesets in the command line. ClusterShell v1.1: $ nodeset -f -x node[3,5-6,9] node[1-9] node[1-2,4,7-8] ClusterShell v1.2+: $ nodeset -f node[1-9] -x node[3,5-6,9] node[1-2,4,7-8] SEE ALSO
clush(1), clubak(1), groups.conf(5). BUG REPORTS
Use the following URL to submit a bug report or feedback: https://github.com/cea-hpc/clustershell/issues AUTHOR
Stephane Thiell, CEA DAM <stephane.thiell@cea.fr> COPYRIGHT
CeCILL-C V1 1.6 2012-03-31 NODESET(1)
All times are GMT -4. The time now is 04:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy