Sponsored Content
Top Forums Shell Programming and Scripting Unix Scripting : Sort a Portion of a File and not the complete file Post 302680873 by evrurs on Thursday 2nd of August 2012 11:31:36 AM
Old 08-02-2012
Unix Scripting : Sort a Portion of a File and not the complete file

Need to sort a portion of a file in a Alphabetical Order.
Example : The user adam is not sorted and the user should get sorted. I don't want the complete file to get sorted.

Currently All_users.txt contains the following lines.

Code:
##############
# ARS USERS
##############
mike, Mike Conway, Stevn Smiley, REQ000001, ARS (11)
paul, Paul Smith, Stevn Smiley, REQ000001, ARS (11)
sam, Sam Martin, Stevn Smiley, REQ000001, ARS (11)
adam, Adam smils, Paul Reily, REQ000001, ARS (11)
#
##############
# ATRIUM USERS
##############
randy, Randy Roch, Steven Seagul, REQ000002, ATRIUM (11)
michelle, Michelle Morques, Steven Seagul, REQ000003, ATRIUM (11)
lois, Lois Hill, Randy Rocker, Steven Seagul, REQ000004, ATRIUM (11)
#
##############
# INSTALLER USERS
##############
nguyen, Nguyen Le, Steven Seagul, REQ000001, INSTALLER (13)
mark, Mark Goodwan, Steven Seagul, REQ000005, INSTALLER (13)

I need the output to be sorted like this.

Code:
##############
 # ARS USERS
 ##############
adam, Adam smils, Paul Reily, REQ000001, ARS (11)
 mike, Mike Conway, Stevn Smiley, REQ000001, ARS (11)
 paul, Paul Smith, Stevn Smiley, REQ000001, ARS (11)
 sam, Sam Martin, Stevn Smiley, REQ000001, ARS (11)
 #
 ##############
 # ATRIUM USERS
 ##############
 randy, Randy Roch, Steven Seagul, REQ000002, ATRIUM (11)
 michelle, Michelle Morques, Steven Seagul, REQ000003, ATRIUM (11)
 lois, Lois Hill, Randy Rocker, Steven Seagul, REQ000004, ATRIUM (11)
 #
 ##############
 # INSTALLER USERS
 ##############
 nguyen, Nguyen Le, Steven Seagul, REQ000001, INSTALLER (13)
 mark, Mark Goodwan, Steven Seagul, REQ000005, INSTALLER (13)

Thanks in advance
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Separate a portion of text file into another file

Hi, I have my input as follows : I have given two entries- From system Mon Aug 1 23:52:47 2005 Source !100000006!: Impact !100000005!: High Status ! 7!: New Last Name+!100000001!: First Name+ !100000003!: ... (4 Replies)
Discussion started by: srikanth_ksv
4 Replies

2. UNIX for Advanced & Expert Users

how to find complete path of a file in unix

hi experts(novice people can stay away as it is no child's game), i am developing a script which works like recycle bin of windows. the problem i am facing is that when ever i am trying to delete a file which is situated in parent directory or parent's parent directory i am unable to capture... (1 Reply)
Discussion started by: yahoo!
1 Replies

3. UNIX for Dummies Questions & Answers

how to find complete path of a file in unix

hi experts(novice people can stay away as it is no child's game), i am developing a script which works like recycle bin of windows. the problem i am facing is that when ever i am trying to delete a file which is situated in parent directory or parent's parent directory i am unable to capture... (5 Replies)
Discussion started by: yahoo!
5 Replies

4. Post Here to Contact Site Administrators and Moderators

Where can I download the VTC - Unix Shell Scripting Advanced complete video

Where can I download the VTC - Unix Shell Scripting Advanced complete video. I don't know in which thread I should post this question.Plz help me out, or just tell me the link in the reply to this post. Thanks in advance. (0 Replies)
Discussion started by: villain41
0 Replies

5. Shell Programming and Scripting

UNix one-liner to sort a file

Hi everyone, I have a txt file as: >001.b1 GCTAGTGCTAGCTAGCTAGCATCGATCGAT >002.b1 CAGTCAGTCGTAGTGCTAGCTGATGCTCGT >003.b1 CGATCGTAGTCGTATCGATGCTGACGTAGG >002.g1 ATGCTGATCGACTAGCTAGTCGT >015.b1 CGATCTAGTAGTGCTAGTCGTTT >001.g1 ATGCTGATCGACTAGCTAGTCGT >003.g1 CGATGCTAGTCGATGCTGACGGG (3 Replies)
Discussion started by: ad23
3 Replies

6. UNIX for Dummies Questions & Answers

Unable to sort file name in Unix

Hi, I'm unable to sort the files with the required names on Unix. Details have been enclosed:- Below are the fle name inside a folder, now i need to sort them in a way that they are group with the seconds occurance in the file name (E.g 01954,07947,06794) 01.01954.MXRS1.rcv... (3 Replies)
Discussion started by: kkkk_ssss
3 Replies

7. Shell Programming and Scripting

How to search and append words in the same file using unix scripting file operations

Hi , I have a file myhost.txt which contains below, 127.0.0.1 localhost 1.17.1.5 atrpx958 11.17.10.11 atrpx958zone nsybhost I need to append words only after "atrpx958" like 'myhost' and 'libhost' and not after atrpx958zone. How to search the word atrpx958(which is hostname) only,... (5 Replies)
Discussion started by: gsreeni
5 Replies

8. Shell Programming and Scripting

How to find complete file names in UNIX if i know only extention of file

Suppose I have a file which contains other file names with some extention . text file containt gdsds sd8ef g/f/temp_temp.sum yyeta t/unix.sum ghfp hrwer h/y/test.text.dat if then.... I want to get the complete file names, like for above file I should get output as temp_temp.sum... (4 Replies)
Discussion started by: panchal
4 Replies

9. UNIX for Dummies Questions & Answers

How to append portion of a file content to another file when a certain pattern is matching?

Hi ladies and gentleman.. I have two text file with me. I need to replace one of the file content to another file if one both files have a matching pattern. Example: text1.txt: ABCD 1234567,HELLO_WORLDA,HELLO_WORLDB DCBA 3456789,HELLO_WORLDE,HELLO_WORLDF text2.txt: XXXX,ABCD... (25 Replies)
Discussion started by: bananamen
25 Replies

10. Shell Programming and Scripting

Read csv file, convert the data and make one text file in UNIX shell scripting

I have input data looks like this which is a part of a csv file 7,1265,76548,"0102:04" 8,1266,76545,"0112:04" I need to make the output data should look like this and the output data will be part of text file: 7|1265000 |7654899 |A| 8|12660000 |76545999 |B| The logic behind the... (6 Replies)
Discussion started by: RJG
6 Replies
tran_init_pkt(9E)						Driver Entry Points						 tran_init_pkt(9E)

NAME
tran_init_pkt, tran_destroy_pkt - SCSI HBA packet preparation and deallocation SYNOPSIS
#include <sys/scsi/scsi.h> struct scsi_pkt *prefixtran_init_pkt(structscsi_address *ap, struct scsi_pkt *pkt, struct buf *bp, int cmdlen, int statuslen, int tgtlen, int flags, int (*callback, caddr_t),caddr_t arg); void prefixtran_destroy_pkt(struct scsi_address *ap, struct scsi_pkt *pkt); INTERFACE LEVEL
Solaris architecture specific (Solaris DDI). PARAMETERS
ap Pointer to a scsi_address(9S) structure. pkt Pointer to a scsi_pkt(9S) structure allocated in an earlier call, or NULL. bp Pointer to a buf(9S) structure if DMA resources are to be allocated for the pkt, or NULL. cmdlen The required length for the SCSI command descriptor block (CDB) in bytes. statuslen The required length for the SCSI status completion block (SCB) in bytes. tgtlen The length of the packet private area within the scsi_pkt to be allocated on behalf of the SCSI target driver. flags Flags for creating the packet. callback Pointer to either NULL_FUNC or SLEEP_FUNC. arg Always NULL. DESCRIPTION
The tran_init_pkt() and tran_destroy_pkt() vectors in the scsi_hba_tran structure must be initialized during the HBA driver's attach(9E) to point to HBA entry points to be called when a target driver calls scsi_init_pkt(9F) and scsi_destroy_pkt(9F). tran_init_pkt() tran_init_pkt() is the entry point into the HBA which is used to allocate and initialize a scsi_pkt structure on behalf of a SCSI target driver. If pkt is NULL, the HBA driver must use scsi_hba_pkt_alloc(9F) to allocate a new scsi_pkt structure. If bp is non-NULL, the HBA driver must allocate appropriate DMA resources for the pkt, for example, throughddi_dma_buf_setup(9F) or ddi_dma_buf_bind_handle(9F). If the PKT_CONSISTENT bit is set in flags, the buffer was allocated by scsi_alloc_consistent_buf(9F). For packets marked with PKT_CONSIS- TENT, the HBA driver must synchronize any cached data transfers before calling the target driver's command completion callback. If the PKT_DMA_PARTIAL bit is set in flags, the HBA driver should set up partial data transfers, such as setting the DDI_DMA_PARTIAL bit in the flags argument if interfaces such as ddi_dma_buf_setup(9F) or ddi_dma_buf_bind_handle(9F) are used. If only partial DMA resources are available, tran_init_pkt() must return in the pkt_resid field of pkt the number of bytes of DMA resources not allocated. If both pkt and bp are non-NULL, if the PKT_DMA_PARTIAL bit is set in flags, and if DMA resources have already been allocated for the pkt with a previous call to tran_init_pkt() that returned a non-zero pkt_resid field, this request is to move the DMA resources for the subsequent piece of the transfer. The contents of scsi_address(9S) pointed to by ap are copied into the pkt_address field of the scsi_pkt(9S) by scsi_hba_pkt_alloc(9F). tgtlen is the length of the packet private area in the scsi_pkt structure to be allocated on behalf of the SCSI target driver. statuslen is the required length for the SCSI status completion block. If the requested status length is greater than or equal to sizeof(struct scsi_arq_status) and the auto_rqsense capability has been set, automatic request sense (ARS) is enabled for this packet. If the status length is less than sizeof(struct scsi_arq_status), automatic request sense must be disabled for this pkt. If the HBA driver is not capable of disabling ARQ on a per-packet basis and tran_init_pkt() is called with a statuslen that is less than sizeof(struct scsi_arq_status), the driver's tran_init_pkt routine should allocate at least sizeof(struct scsi_arq_status). If an ARS is needed, upon successful ARS done by the HBA driver, the driver must copy the sense data over and set STAT_ARQ_DONE in pkt_state. cmdlen is the required length for the SCSI command descriptor block. Note: tgtlen, statuslen, and cmdlen are used only when the HBA driver allocates the scsi_pkt(9S), in other words, when pkt is NULL. callback indicates what the allocator routines should do when resources are not available: NULL_FUNC Do not wait for resources. Return a NULL pointer. SLEEP_FUNC Wait indefinitely for resources. tran_destroy_pkt() tran_destroy_pkt() is the entry point into the HBA that must free all of the resources that were allocated to the scsi_pkt(9S) structure during tran_init_pkt(). RETURN VALUES
tran_init_pkt() must return a pointer to a scsi_pkt(9S) structure on success, or NULL on failure. If pkt is NULL on entry, and tran_init_pkt() allocated a packet throughscsi_hba_pkt_alloc(9F) but was unable to allocate DMA resources, tran_init_pkt() must free the packet through scsi_hba_pkt_free(9F) before returning NULL. SEE ALSO
attach(9E), tran_sync_pkt(9E), biodone(9F), bioerror(9F), ddi_dma_buf_bind_handle(9F), ddi_dma_buf_setup(9F), scsi_alloc_consis- tent_buf(9F), scsi_destroy_pkt(9F), scsi_hba_attach(9F), scsi_hba_pkt_alloc(9F), scsi_hba_pkt_free(9F), scsi_init_pkt(9F), buf(9S), scsi_address(9S), scsi_hba_tran(9S), scsi_pkt(9S) Writing Device Drivers NOTES
If a DMA allocation request fails with DDI_DMA_NOMAPPING, indicate the error by calling bioerror(9F) with bp and an error code of EFAULT. If a DMA allocation request fails with DDI_DMA_TOOBIG, indicate the error by calling bioerror(9F) with bp and an error code of EINVAL. SunOS 5.10 21 Feb 2003 tran_init_pkt(9E)
All times are GMT -4. The time now is 04:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy