perl -pi -e 's/\x00/\x0d\x0a/g' `grep -l $'[\x00]GS' filelist`
This isn't working , it's not pulling the files that contain the regex. Please help me rewrite this :wall:.
Ideally for this to work on 9K of 20K files in the directory, I've tried this but I don't know enough about awk to make it work.
for each del in `cat delimiters`
do
perl -pi -e 's/\x$del/\x0d\x0a/g' `grep -l $'[\x$del]GS' filelist`
done
cat delimiters
15
1c
1e
1f
GOAL
Subsititute the value at position 106 with a newline for the entire file (preferably when the value at pos 107=G) and preferably this will happen on for files that have a value at position 107 and the line begins with ISA.
ISSUE
- my grep statement looking for specific hex values isn't working
- I'd like to identify and perform the same action on files that share the same value at position 106
- some characters are troublesome in a perl one liner or a grep like \ or - or other hex values
- the file contains other non-ascii or non-printable characters throughout the file that should not be substituted
This value at position 106 - changes from file to file
- is consistent within a particular file
- is non-word, usually non-ascii or non-printable (ie hex value 15, 1c, 1e, 1f, 21, 27, 2a, 2e, 3c, 3d, 3e, 3f, 40, 5c, 5e, 60, 7d, 7e, b8, be, c4, 00)
- may not be at position 106 in other files and should not be subsituted in files that do not have this value at pos 106
INPUT: This is what the input file looks like. The value at position 106 is Hex x00
ISA`00`FTL DATA `00`FTL DATA `ZZ`BBBB MFG `ZZ`FFF MFG `110612`1931`U`00401`000001527`0`P`> GS`FA`BBBB MFG`FFF MFG`110612`1931`940`X`002040 ST`997`000001184 AK1`PO`214 AK2`830`000007903 AK5`A AK9`A`1`1`1 SE`6`000001184 GE`1`940 IEA`1`000001527-
or
The value at position 106 is Hex x27. Hex x60 is throughout the file and shouldn't be substituted.
ISA`00`FTL DATA `00`FTL DATA `ZZ`B715 MFG `ZZ`FTL MFG `110612`1931`U`00401`000001527`0`P`>'GS`FA`B715 MFG`FTL MFG`110612`1931`940`X`002040'ST`997`000001184'AK1`PO`214'AK2`830`000007903'AK5`A'AK9`A`1`1`1'SE`6`000001184'GE`1`940'IEA`1`000001527-
OUTPUT: This is what the output should look like.
ISA`00`FTL DATA `00`FTL DATA `ZZ`BBBB MFG `ZZ`FFF MFG `110612`1931`U`00401`000001527`0`P`>
GS`FA`BBBB MFG`FFF MFG`110612`1931`940`X`002040
ST`997`000001184
AK1`PO`214
AK2`830`000007903
AK5`A
AK9`A`1`1`1
SE`6`000001184
GE`1`940
IEA`1`000001527-