Sponsored Content
Full Discussion: Sorting a specific column!
Top Forums Shell Programming and Scripting Sorting a specific column! Post 302950640 by ajetangay on Monday 27th of July 2015 01:31:02 PM
Old 07-27-2015
Display Sorting a specific column!

What im trying to do is sort the output by the number on the second column and than limit the result to only the first three lines.

This is the code

Code:
idlist="x23s52; f34233; 2343xs; 25x34; si342d"
cntr=1
idcnt=$(print $nidlist |tr ';' '\n' |wc -l)
numofgrps=0
while (($cntr <= $idcnt))
do
    idlist=$idlist\;
    numofgrps=$numofgrps\;
    currid=$(print $idlist |awk -F ';' '{print  $1}')
    numofgrps=`cat /home/n5ddc8/BI_Ab_Intito_dist/BI_Ab_Initio_dist.report.dat | grep $currnid | wc -l`
    currcnt="$currid$numofgrps \n"
    toplst=$toplst   $currcnt
    idlist=${idlist#*\;}
    cntr=$(($cntr + 1))
done
print $toplst

The output of this code looks something like this.

Code:
x23s52   3
f34233   2
21jh43   1
ad34nj   5

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert a text from a specific row into a specific column using SED or AWK

Hi, I am having trouble converting a text file. I have been working for this whole day now, still i couldn't make it. Here is how the text file looks: _______________________________________________________ DEVICE STATUS INFORMATION FOR LOCATION 1: OPER STATES: Disabled E:Enabled ... (5 Replies)
Discussion started by: Issemael
5 Replies

2. Shell Programming and Scripting

Assigning a specific format to a specific column in a text file using awk and printf

Hi, I have the following text file: 8 T1mapping_flip02 ok 128 108 30 1 665000-000008-000001.dcm 9 T1mapping_flip05 ok 128 108 30 1 665000-000009-000001.dcm 10 T1mapping_flip10 ok 128 108 30 1 665000-000010-000001.dcm 11 T1mapping_flip15 ok 128 108 30... (2 Replies)
Discussion started by: goodbenito
2 Replies

3. Shell Programming and Scripting

Sorting multi-column values from a specific file

Hi, all. I need a shell script which gathers data from a remote XML file and then displays it according to my needs.. I need this for my job due to the fact that I need to keep track price changes of euro, usd, gold, etc. The XML file I am talking about is located at this page: cnnturk dot... (4 Replies)
Discussion started by: canimsin
4 Replies

4. Shell Programming and Scripting

Replace column that matches specific pattern, with column data from another file

Can anyone please help with this? I have 2 files as given below. If 2nd column of file1 has pattern foo1@a, find the matching 1st column in file2 & replace 2nd column of file1 with file2's value. file1 abc_1 foo1@a .... abc_1 soo2@a ... def_2 soo2@a .... def_2 foo1@a ........ (7 Replies)
Discussion started by: prashali
7 Replies

5. Shell Programming and Scripting

Count specific characters at specific column positions

Hi all, I need help. I have an input text file (input.txt) like this: 21 GTGCAACACCGTCTTGAGAGG 50 21 GACCGAGACAGAATGAAAATC 73 21 CGGGTCTGTAGTAGCAAACGC 108 21 CGAAAAATGAACCCCTTTATC 220 21 CGTGATCCTGTTGAAGGGTCG 259 Now I need to count A/T/G/C numbers at each character location in column... (2 Replies)
Discussion started by: thienxho
2 Replies

6. Shell Programming and Scripting

[Solved] Sorting a column based on another column

hello, I have a file as follows: F0100010 A C F0100040 A G BTA-28763-no-rs 77.2692 F0100020 A G F0100030 A T BTA-29334-no-rs 11.4989 F0100030 A T F0100020 A G BTA-29515-no-rs 127.006 F0100040 A G F0100010 A C BTA-29644-no-rs 7.29827 F0100050 A... (9 Replies)
Discussion started by: Homa
9 Replies

7. Shell Programming and Scripting

Converting Single Column into Multiple rows, but with strings to specific tab column

Dear fellows, I need your help. I'm trying to write a script to convert a single column into multiple rows. But it need to recognize the beginning of the string and set it to its specific Column number. Each Line (loop) begins with digit (RANGE). At this moment it's kind of working, but it... (6 Replies)
Discussion started by: AK47
6 Replies

8. Shell Programming and Scripting

How to print multiple specific column after a specific word?

Hello.... Pls help me (and sorry my english) :) So I have a file (test.txt) with 1 long line.... for example: isgc jsfh udgf osff 8462 error iwzr 653 idchisfb isfbisfb sihfjfeb isfhsi gcz eifh How to print after the "error" word the 2nd 4th 5th and 7th word?? output well be: 653 isfbisfb... (2 Replies)
Discussion started by: marvinandco
2 Replies

9. Shell Programming and Scripting

Overwrite specific column in xml file with the specific column from adjacent line

I have an xml file dumped from rrd file, that I want to "patch" so the xml file doesn't contain any blank hole in the resulting graph of the rrd file. Here is the file. <!-- 2015-10-12 14:00:00 WIB / 1444633200 --> <row><v> 4.0419731265e+07 </v><v> 4.5045912770e+06... (2 Replies)
Discussion started by: rk4k
2 Replies

10. Shell Programming and Scripting

Using awk to change a specific column and in a specific row

I am trying to change the number in bold to 2400 01,000300032,193631306,190619,0640,1,80,,2/ 02,193631306,000300032,1,190618,0640,CAD,2/ I'm not sure if sed or awk is the answer. I was going to use sed and do a character count up to that point, but that column directly before 0640 might... (8 Replies)
Discussion started by: juggernautjoee
8 Replies
HBA_SendCTPassThru(3HBAAPI)		      Common Fibre Channel HBA Information Library Functions		       HBA_SendCTPassThru(3HBAAPI)

NAME
HBA_SendCTPassThru, HBA_SendCTPassThruV2 - end a Fibre Channel Common Transport request to a Fabric SYNOPSIS
cc [ flag... ] file... -lHBAAPI [ library... ] #include <hbaapi.h> HBA_STATUS HBA_SendCTPassThru(HBA_HANDLE handle, void *pReqBuffer, HBA_UINT32 ReqBufferSize, void *pRspBuffer, HBA_UINT32 RspBufferSize); HBA_STATUS HBA_SendCTPassThruV2(HBA_HANDLE handle, HBA_WWN hbaPortWWN, void *pReqBuffer, HBA_UINT32 ReqBufferSize, void *pRspBuffer, HBA_UINT32 *RspBufferSize); PARAMETERS
handle an open handle returned from HBA_OpenAdapter(3HBAAPI) hbaPortWWN the Port Name of the local HBA Port through which the caller is issuing the CT request pReqBuffer a pointer to a CT_IU request. The contents of the buffer must be in big-endian byte order ReqBufferSize the length of the CT_IU request buffer pReqBuffer pRspBuffer a pointer to a CT_IU response buffer. The response received from the fabric is copied into this buffer in big-endian byte order. Success of the function need not imply success of the command. The CT_IU Command/Response field should be checked for the Accept Response code. RspBufferSize HBA_SendCTPassThru() the length of the CT_IU accept response buffer pRspBuffer. HBA_SendCTPassThruV2() a Pointer to the length of the CT_IU accept response buffer pRspBuffer. DESCRIPTION
The HBA_SendCTPassThru() and HBA_SendCTPassThruV2() functions provide access to the standard in-band fabric management interface. The pRe- qBuffer argument is interpreted as a CT_IU request, as defined by the T11 specification FC-GS-3, and is routed in the fabric based on the GS_TYPE field. RETURN VALUES
Upon successful transport and receipt of a CT_IU response, HBA_SendCTPassThru() returns HBA_STATUS_OK. The CT_IU payload indicates whether the command was accepted by the fabric based on the Command/Response code returned. Otherwise, an error value is returned from the under- lying VSL and the values in pRspBuffer are undefined. Upon successful transport and receipt of a CT_IU response, HBA_SendCTPassThruV2() returns HBA_STATUS_OK. The CT_IU payload indicates whether the command was accepted by the fabric based on the Command/Response code returned. Otherwise, an error code is returned from the underlying VSL, and the values in pRspBuffer are undefined. The HBA_SendCTPassThruV2() function returns the following values: HBA_STATUS_ERROR_ILLEGAL_WWN The value of hbaPortWWN is not a valid port WWN on the specified HBA. HBA_STATUS_ERROR An error occurred. ERRORS
See libhbaapi(3LIB) for general error status values. EXAMPLES
Example 1: Data structures for the GIEL command. struct ct_iu_preamble { uint32_t ct_rev : 8, ct_inid : 24; uint32_t ct_fcstype : 8, ct_fcssubtype : 8, ct_options : 8, ct_reserved1 : 8; uint32_t ct_cmdrsp : 16, ct_aiusize : 16; uint32_t ct_reserved2 : 8, ct_reason : 8, ct_expln : 8, ct_vendor : 8; }; struct gs_ms_ic_elem { uchar_t elem_name[8]; uint32_t reserved1 : 24, elem_type : 8; }; struct gs_ms_giel_rsp { struct ct_iu_preamble ct_header; uint32_t num_elems; struct gs_ms_ic_elem elem_list[1]; }; #define MAX_PAYLOAD_LEN 65536 /* 64K */ Example 2: Send an GIEL Management Service command through the given HBA handle. The following example sends an GIEL Management Service command through the given HBA handle. req.ct_rev = 0x01; req.ct_fcstype = 0xFA; /* Management Service */ req.ct_fcssubtype = 0x01; /* Config server */ req.ct_cmdrsp = 0x0101; /* GIEL command */ req.ct_aiusize = MAX_PAYLOAD_LEN / 4 - sizeof (struct ct_iu_preamble) / 4; if ((status = HBA_SendCTPassThru(handle, &req, sizeof (req), rsp, MAX_PAYLOAD_LEN)) != HBA_STATUS_OK) { fprintf(stderr, "Unable to issue CT command on " for reason %d0, adaptername, status); } else { giel = (struct gs_ms_giel_rsp *)rsp; if (giel->ct_header.ct_cmdrsp != 0x8002) { fprintf(stderr, "CT command rejected on HBA " " } else { for (cntr = 0; cntr < giel->num_elems; cntr++) { memcpy(&wwn, giel->elem_list[cntr].elem_name, 8); printf(" Fabric element name: %016llx0, wwn); } } } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard: FC-MI 1.92 (API | | |version 1) | +-----------------------------+-----------------------------+ | |Standard: FC-HBA Version 4 | | |(API version 2) | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
HBA_OpenAdapter(3HBAAPI), libhbaapi(3LIB), attributes(5) T11 FC-MI Specification BUGS
The HBA_SendCTPassThru() function does not take a portindex to define through which port of a multi-ported HBA to send the command. The behavior on multi-ported HBAs is vendor specific, and can result in the command always being sent on port 0 of the HBA. SNIA version 2 defines HBA_SendCTPassThruV2() which takes a Port WWN as an argument. This fixes the bug with multi-ported HBAs in HBA_SendCTPassThru(). SunOS 5.10 1 Sep 2003 HBA_SendCTPassThru(3HBAAPI)
All times are GMT -4. The time now is 03:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy