Sponsored Content
Top Forums Shell Programming and Scripting Help search and replace hex values only in specific files Post 302531456 by verge on Thursday 16th of June 2011 09:37:14 PM
Old 06-16-2011
Thanks so much mirni ... I really appreciate it.

Now that I've seen your code, this solves more than one issue for me. If c109 is present then yes ... all the code needs to be executed.

This saves time because the field will be empty for files that don't require this code.

Thanks!

Brackets! But of course ...

---------- Post updated at 06:37 PM ---------- Previous update was at 06:28 PM ----------

Can you help me figure out the next part of my script? How I can use awk to print a new line with every occurence of AK2 (plus the other variables). I can show you the awk I've already started, it isn't quite right, it's only giving me one line w the first AK2($2) and it skips the others. Smilie

Code:
INPUT looks like this:
ISA~00~          ~00~          ~ZZ~RRRR           ~ZZ~FFF FIAC       ~110611~2215~U~00301~000002391~0~P~>
GS~FA~RRRR MFG~FFFXMFG~110611~2215~1847~X~002000
ST~997~1751
AK1~PO~970
AK2~830~000031588 #I want to print the other variables for every occurrence of AK2
AK5~A
AK2~830~000031589
AK5~A
AK2~830~000031590
AK5~A
AK2~830~000031607
AK5~A
AK9~A~186~186~186
SE~376~1751
GE~1~1847
IEA~1~000002391
 
I'd like the OUTPUT to look this:
RRRR           ,FFF FIAC       ,000002391,FA,RRRR MFG,1847,PO,970,830,000031588,,,,,,A,,A,186,186,186,,
RRRR           ,FFF FIAC       ,000002391,FA,RRRR MFG,1847,PO,970,830,000031589,,,,,,A,,A,186,186,186,,
RRRR           ,FFF FIAC       ,000002391,FA,RRRR MFG,1847,PO,970,830,000031590,,,,,,A,,A,186,186,186,,
RRRR           ,FFF FIAC       ,000002391,FA,RRRR MFG,1847,PO,970,830,000031607,,,,,,A,,A,186,186,186,,

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

highly specific search and replace for a large number of files

hey guys, I have a directory with about 600 files. I need to find a specific word inside a command and replace only that instance of the word in many files. For example, lets say I have a command called 'foo' in many files. One of the input arguments of the 'foo' call is 'bar'. The word 'bar'... (5 Replies)
Discussion started by: ksubrama
5 Replies

2. Programming

searching files for hex or oct values

I have a set of files without extensions. How can I programatically tell if a file is in gzip format? The gzip file format spec RFC 1952 GZIP File Format Specification version 4.3 states that gzip files have certain hex/oct values at the beginning of the file. 1st byte = 0x1f in hex,... (2 Replies)
Discussion started by: daflore
2 Replies

3. Shell Programming and Scripting

Search for multiple string and replace with respective values

Hi, Can anyone help me to search for multiple strings within specified position and replace with respective string value. For example I need to search the string from the position 11 to 20 and if it contain ABC and then replace it by BCDEFGHIJ ... find AABZSDJIK and replace with QWE. and... (4 Replies)
Discussion started by: zooby
4 Replies

4. UNIX for Advanced & Expert Users

Search and replace a array values in perl

Hi, i want to search and replace array values by using perl perl -pi -e "s/${d$i]}/${b$j]}" *.xml i am using while loop for the same. if i excute this,it shows "Substitution replacement not terminated at -e line 1.". please tell me what's wrong this line (1 Reply)
Discussion started by: arindam guha
1 Replies

5. Shell Programming and Scripting

Query the table and return values to shell script and search result values from another files.

Hi, I need a shell script, which would search the result values from another files. 1)execute " select column1 from table_name" query on the table. 2)Based on the result, need to be grep from .wft files. could please explain about this.Below is the way i am using. #!/bin/sh... (4 Replies)
Discussion started by: Rami Reddy
4 Replies

6. Shell Programming and Scripting

awk to search for specific line and replace nth column

I need to be able to search for a string in the first column and if that string exists than replace the nth column with "-9.99". AW12000012012 2.38 1.51 3.01 1.66 0.90 0.91 1.22 0.82 0.57 1.67 2.31 3.63 0.00 AW12000012013 1.52 0.90 1.20 1.34 1.21 0.67 ... (14 Replies)
Discussion started by: ncwxpanther
14 Replies

7. Shell Programming and Scripting

How to replace with "sed" some hex values by other hex values?

Assume I have a file \usr\home\\somedir\myfile123.txt and I want to replace all occurencies of the two (concatenated) hex values x'AD' x'A0' bytwo other (concatenated) hex values x'20' x'6E' How can I achieve this with the gnu sed tool? Additional question: Is there a way to let sed show... (1 Reply)
Discussion started by: pstein
1 Replies

8. Shell Programming and Scripting

Search Replace Specific Column using RegEx

Have Pipe Delimited File: > BRYAN BAKER|4/4/2015|518 VIRGINIA AVE|TEST > JOE BAXTER|3/30/2015|2233 MockingBird RD|ROW2On 3rd column where the address is located, I want to add a space after every numeric value - basically doing a "s//&\ / ": > BRYAN BAKER|4/4/2015|5 1 8 VIRGINIA AVE|TEST > JOE... (5 Replies)
Discussion started by: svn
5 Replies

9. Shell Programming and Scripting

Search and replace specific positions of specific lines

Hi, I have a file with hundreds of lines. I want to search for particular lines starting with 4000, search and replace the 137-139 position characters; which will be '000', with '036'. Can all of this be done without opening a temp file and then moving that temp file to the original file name. ... (7 Replies)
Discussion started by: dsid
7 Replies

10. UNIX for Advanced & Expert Users

Replace hex values using sed command

File lalo.txt contains: Á I need to replace Á by A using sed command. od -x lalo.txt 0000000 c10a 0000002 sed -e 's/\xc1\x0a/A/g' lalo.txt > lalo2.txt Also tried: sed -e 's/\xc3\x81/A/g' lalo.txt > lalo2.txt Output file lalo2.txt still has Á Unix version: SunOS 5.11 ... (9 Replies)
Discussion started by: mrreds
9 Replies
scsi(4) 							   File Formats 							   scsi(4)

NAME
scsi - configuration files for SCSI target drivers DESCRIPTION
The architecture of the Solaris SCSI subsystem distinguishes two types of device drivers: SCSI target drivers, and SCSI host adapter driv- ers. Target drivers like sd(7D) and st(7D) manage the device on the other end of the SCSI bus. Host adapter drivers manage the SCSI bus on behalf of all the devices that share it. Drivers for host adapters provide a common set of interfaces for target drivers. These interfaces comprise the Sun Common SCSI Architecture ( SCSA) which are documented as part of the Solaris DDI/DKI. See scsi_ifgetcap(9F), scsi_init_pkt(9F), and scsi_transport(9F) for further details of these, and associated routines. Depending on the interconnect (transport), SCSI target devices are either self-identifying or rely on driver.conf(4) entries to be recog- nized by the system. For self-identifying target devices the driver binding is chosen based on the IEEE-1275 like 'compatible' forms of the target devices. Currently only the Fibre Channel interconnects, fcp(7D), ifp(7D), scsi_vhci(7D), sf(7D), are self-identifying. You must specify other ipossible interconnects target devices by using the target driver driver.conf(4) configuration files. Self-Identifying Host adapter drivers that dynamically create self-identifying target device children establish a "compatible" property on each child. The "compatible" property is an ordered array of strings, each string is a compatible "form". High precedence forms are defined first. For a particular device, the highest precedence form that has an established driver alias selects the driver for the device. Driver associations to compatible forms, called aliases, are administered by way of add_drv(1M), update_drv(1M), and rem_drv(1M) utilities. The forms for self-identifying SCSI target devices are derived from the SCSI target device's INQUIRY data. A diverse set of forms is defined, allowing for flexibility in binding. From the SCSI INQUIRY data, three types of information are extracted: scsi_dtype, flag bits, and SCSI_ASCII vendor product revision. The scsi_dtype is the first component of most forms. It is represented as two hex digits. For nodes that represent embedded secondary func- tions, such as an embedded enclosure service or media changer, additional forms are generated that contain the dtype of the secondary func- tion followed by the dtype of the device in which the secondary function is embedded. For forms that use flag bits, all applicable flags are concatenated (in alphabetical order) into a single flags string. Removable media is represented by a flag. For forms that use the SCSI_ASCII INQUIRY vendor, product, and revision fields, a one-way conversion algorithm translates SCSI_ASCII to a IEEE 1275 compatible string. It is possible that a device might change the INQUIRY data it returns over time as a result of a device initialization sequence or in response to out-of-band management. A device node's "compatible" property is based on the INQUIRY data when the device node was created. The following forms, in high to low precedence order, are defined for SCSI target device nodes. scsiclass,DDEEFFF.vVVVVVVVV.pPPPPPPPPPPPPPPPP.rRRRR (1 *1&2) scsiclass,DDEE.vVVVVVVVV.pPPPPPPPPPPPPPPPP.rRRRR (2 *1) scsiclass,DDFFF.vVVVVVVVV.pPPPPPPPPPPPPPPPP.rRRRR (3 *2) scsiclass,DD.vVVVVVVVV.pPPPPPPPPPPPPPPPP.rRRRR(4) scsiclass,DDEEFFF.vVVVVVVVV.pPPPPPPPPPPPPPPPP (5 *1&2) scsiclass,DDEE.vVVVVVVVV.pPPPPPPPPPPPPPPPP (6 *1) scsiclass,DDFFF.vVVVVVVVV.pPPPPPPPPPPPPPPPP (7 *2) scsiclass,DD.vVVVVVVVV.pPPPPPPPPPPPPPPPP(8) scsiclass,DDEEFFF (9 *1&2) scsiclass,DDEE (10 *1) scsiclass,DDFFF (11 *2) scsiclass,DD(12) scsiclass(13) *1 only produced on a secondary function node *2 only produced on a node with flags where: v Is the letter v. Denotes the beginning of VVVVVVVV. VVVVVVVV Translated scsi_vendor: SCSI standard INQUIRY data "Vendor identification" SCSI_ASCII field (bytes 8-15). p Is the letter p. Denotes the beginning of PPPPPPPPPPPPPPPP. PPPPPPPPPPPPPPPP Translated scsi_product: SCSI standard INQUIRY data "Product identification" SCSI_ASCII field (bytes 16-31). r Is the letter r. Denotes the beginning of RRRR. RRRR Translated scsi_revision: SCSI standard INQUIRY data "Product revision level" SCSI_ASCII field (bytes 32-35). DD Is a two digit ASCII hexadecimal number. The value of the two digits is based one the SCSI "Peripheral device type" command set associ- ated with the node. On a primary node this is the scsi_dtype of the primary command set; on a secondary node this is the scsi_dtype associated with the embedded function command set. EE Same encoding used for DD. This form is only generated on secondary function nodes. The DD function is embedded in an EE device. FFF Concatenation, in alphabetical order, of the flag characters below. The following flag characters are defined: R Removable media: Used when scsi_rmb is set Forms using FFF are only be generated if there are applicable flag characters. Solaris might create additional compatible forms not described. These forms are for Solaris internal use only. Any additional use of these forms is discouraged. Future releases of Solaris might not produce these forms. driver.conf Configuration files for SCSI target drivers should identify the host adapter driver implicitly using the class keyword to remove any depen- dency on the particular host adapter involved. All host adapter drivers of class scsi recognize the following properties: target Integer-valued SCSI target identifier that this driver claims. lun Integer-valued SCSI logical unit number ( LUN) that this driver claims. All SCSI target driver configuration file device definitions must provide target and lun properties. These properties are used to construct the address part of the device name under /devices. The SCSI target driver configuration files shipped with Solaris have entries for LUN 0 only. For devices that support other LUNs, such as some CD changers, the system administrator can edit the driver configuration file to add entries for other LUNs. EXAMPLES
Example 1: An Example Configuration File for a SCSI Target Driver The following is an example configuration file for a SCSI target driver called toaster.conf. # # Copyright (c) 1992, by Sun Microsystems, Inc. # #ident "@(#)toaster.conf 1.2 92/05/12 SMI" name="toaster" class="scsi" target=4 lun=0; Add the following lines to sd.conf for a six- CD changer on target 3, with LUNs 0 to 5. name="sd" class="scsi" target=3 lun=1; name="sd" class="scsi" target=3 lun=2; name="sd" class="scsi" target=3 lun=3; name="sd" class="scsi" target=3 lun=4; name="sd" class="scsi" target=3 lun=5; It is not necessary to add the line for LUN 0, as it already exists in the file shipped with Solaris. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWckr | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
add_drv(1M), rem_drv(1M), update_drv(1M), driver.conf(4), attributes(5), fcp(7D), ifp(7D), scsi_vhci(7D), sd(7D), sf(7D), st(7D), scsi_ifgetcap(9F), scsi_init_pkt(9F), scsi_transport(9F) Writing Device Drivers ANS X3T9.2/82-2 SMALL COMPUTER SYSTEM INTERFACE (SCSI-1) ANS X3T9.2/375D Small Computer System Interface - 2 (SCSI-2) ANS X3T10/994D SCSI-3 Architecture Model (SAM) IEEE 1275 SCSI Target Device Binding NOTES
With driver.conf(4) configuration, you need to ensure that the target and lun values claimed by your target driver do not conflict with existing target drivers on the system. For example, if the target is a direct access device, the standard sd.conf file usually makes sd claim it before any other driver has a chance to probe it. SunOS 5.10 26 Sep 2004 scsi(4)
All times are GMT -4. The time now is 03:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy