Sponsored Content
Top Forums Shell Programming and Scripting Find key pattern and print selected lines for each record Post 302943908 by Chubler_XL on Thursday 14th of May 2015 12:21:23 AM
Old 05-14-2015
How about this

Code:
awk '
BEGIN{
   for(i=split("ID ACC TOS TMA KAW FEA TT", k);i;i--) keep[k[i]];
}
$1 in keep     { s=s "\n" $0 }
/^DOR[ \t]+TDP/{ s=s "\n" $0 }
$1=="COM" && /-@- Full Comment/ {
   s=s "\n" $0; getline
   s=s "\n" $0
}
/^FEA.*SUBCHAN/ { tt++ }
$1=="##"&&s {
   if(prn) print "##" s "\nTT   " tt
   s=""
   tt=prn=0
}
/^KAW.*subchannel/ {prn++}
END { print "##" } ' infile

These 2 Users Gave Thanks to Chubler_XL For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

print selected lines

Hi everybody: I try to print in new file selected lines from another file wich depends on the first column. I have done a script like this: lines=( "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "21" "31" "41" "51" "55" "57" "58" ) ${lines} for lines in ${lines} do awk -v ... (6 Replies)
Discussion started by: tonet
6 Replies

2. Shell Programming and Scripting

Grep for a pattern and print entire record

Hi friends, This is my very first post on forum, so kindly excuse if my doubts are found too silly. I am trying to automate a piece of routine work and this is where I am stuck at the moment-I need to grep a particular ID through a file containing many records(which start with <LRECORD> and end... (6 Replies)
Discussion started by: faiz1985
6 Replies

3. Shell Programming and Scripting

trying to print selected fields of selected lines by AWK

I am trying to print 1st, 2nd, 13th and 14th fields of a file of line numbers from 29 to 10029. I dont know how to put this in one code. Currently I am removing the selected lines by awk 'NR==29,NR==10029' File1 > File2 and then doing awk '{print $1, $2, $13, $14}' File2 > File3 Can... (3 Replies)
Discussion started by: ananyob
3 Replies

4. Shell Programming and Scripting

Print selected lines from file in order

I need to extract selected lines from a log file, I can use grep to pull one line matching 'x' or matching 'y', how can I run through the log printing both matching lines in order top to bottom. i.e line 1 xyz - not needed line 2 User01 - needed line 3 123 - not needed line 4 Info - needed... (2 Replies)
Discussion started by: rosslm
2 Replies

5. Shell Programming and Scripting

Help with print out all relevant record if match particular pattern

Input file: data100_content1 420 700 data101_content1 107 516 data101_content2 194 773 data101_content3 195 917 data104_content2 36 325 data105_content1 505 605 data106_content1 291 565 ... (7 Replies)
Discussion started by: perl_beginner
7 Replies

6. Shell Programming and Scripting

awk to print record not equal specific pattern

how to use "awk" to print any record has pattern not equal ? for example my file has 5 records & I need to get all lines which $1=10 or 20 , $2=10 or 20 and $3 greater than "130302" as it shown : 10 20 1303252348212B030 20 10 1303242348212B030 40 34 1303252348212B030 10 20 ... (14 Replies)
Discussion started by: arm
14 Replies

7. Shell Programming and Scripting

Gawk Find Pattern Print Lines Before and After

Using grep I can easily use: cvs log |grep -iB 10 -A 10 'date: 2013-10-30' to display search results and 10 lines before and after. How can this be accompished using gawk? (4 Replies)
Discussion started by: metallica1973
4 Replies

8. Shell Programming and Scripting

Shell Script @ Find a key word and If the key word matches then replace next 7 lines only

Hi All, I have a XML file which is looks like as below. <<please see the attachment >> <?xml version="1.0" encoding="UTF-8"?> <esites> <esite> <name>XXX.com</name> <storeId>10001</storeId> <module> ... (4 Replies)
Discussion started by: Rajeev_hbk
4 Replies

9. Shell Programming and Scripting

Help with print out record if first and next line follow specific pattern

Input file: pattern1 100 250 US pattern2 50 3050 UK pattern3 100 250 US pattern1 70 1050 UK pattern1 170 450 Mal pattern2 40 750 UK . . Desired Output file: pattern1 100 250 US pattern2 50 3050 UK pattern1 170 450 Mal pattern2... (3 Replies)
Discussion started by: cpp_beginner
3 Replies

10. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies
SG_SAT_SET_FEATURES(8)						     SG3_UTILS						    SG_SAT_SET_FEATURES(8)

NAME
sg_sat_set_featutes - sends a ATA SET FEATURES command via a SCSI to ATA Translation (SAT) layer SYNOPSIS
sg_sat_set_features [--count=CO] [--chk_cond] [--feature=FEA] [--help] [--len=16|12] [--lba=LBA] [--verbose] [--version] DEVICE DESCRIPTION
This utility sends an ATA SET FEATURES command to the DEVICE. This command is used to change settings of ATA non-packet (i.e. disks) and packet devices (e.g. cd/dvd drives). Rather than send the SET FEATURES command directly to the device it is sent via a SCSI transport which is assumed to contain a SCSI to ATA Translation (SAT) Layer (SATL). The SAT standard (SAT ANSI INCITS 431-2007; prior draft: sat-r09.pdf at www.t10.org) defines two SCSI "ATA PASS-THROUGH" commands: one using a 16 byte "cdb" and the other with a 12 byte cdb. This utility defaults to the 16 byte cdb variant. The SATL may be in an operating system driver, in host bus adapter firmware or in some external enclosure. The features can be read using the sg_sat_identify utility which uses either the ATA IDENTIFY DEVICE (for non-packet devices) or the IDEN- TIFY PACKET DEVICE (for packet devices) command. OPTIONS
Arguments to long options are mandatory for short options as well. -c, --count=CO the number CO is placed in the "count" field in the ATA SET FEATURES command. Only some subcommands (a term used for the value placed in the "feature" field) require the count field to be set. The default value placed in the "count" field is 0. -C, --chk_cond sets the CK_COND bit in the ATA PASS-THROUGH SCSI cdb. The default setting is clear (i.e. 0). When set the SATL should yield a sense buffer containing a ATA Result descriptor irrespective of whether the ATA command succeeded or failed. When clear the SATL should only yield a sense buffer containing a ATA Result descriptor if the ATA command failed. -f, --feature=FEA the value FEA is placed in the "feature" field in the ATA SET FEATURES command. The term "subcommand" is sometimes used for this value. The default value placed in the "feature" field is 0 which is reserved and hence should not change anything. Two common exam- ples are 2h to enable the write cache and 82h to disable it. -h, --help outputs the usage message summarizing command line options then exits. Ignores DEVICE if given. -l, --len=16 | 12 this is the length of the SCSI cdb used for the ATA PASS-THROUGH commands. The argument can either be 16 or 12. The default is 16. Some SCSI transports cannot convey SCSI commands longer than 12 bytes. -L, --lba=LBA the number LBA is placed in the "lba" field in the ATA SET FEATURES command. Only some subcommands (a term used for the value placed in the "feature" field) require the lba field to be set. This value is not a "logical block address" as the acronym might imply. The default value placed in the "lba" field is 0. -v, --verbose increases the level or verbosity. -V, --version print out version string NOTES
In the 2.4 series of Linux kernels the DEVICE must be a SCSI generic (sg) device. In the 2.6 series block devices (e.g. disks and ATAPI DVDs) can also be specified. For example "sg_inq /dev/sda" will work in the 2.6 series kernels. From lk 2.6.6 other SCSI "char" device names may be used as well (e.g. "/dev/st0m"). EXIT STATUS
The exit status of sg_sat_set_features is 0 when it is successful. Otherwise see the sg3_utils(8) man page. AUTHOR
Written by Doug Gilbert REPORTING BUGS
Report bugs to <dgilbert at interlog dot com>. COPYRIGHT
Copyright (C) 2007 Douglas Gilbert This software is distributed under a FreeBSD license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR- POSE. SEE ALSO
sg_sat_identify(sg3_utils), sg_inq(sg3_utils), sdparm(sdparm), hdparm(hdparm) sg3_utils-1.25 August 2007 SG_SAT_SET_FEATURES(8)
All times are GMT -4. The time now is 08:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy