|
||||||
| Forums FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Novell Archives Archived content from Novell openSUSE support forums |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi, I'm in the process of cleaning up a few old ASCII text files that came
from another old PC. I am some what new with scripts and have checked the web for how to use sed to strip all occurances of hex x80 - xFF in all of the records in these files. Here is the code I'm using, but for some reason it is not striping/dropping the hex characters in the desired range. Exam B0 not dropped. RemovedHexRecord=`echo $OrgRecord \ | sed -e 's/x12[89]//g' \ -e 's/x1[3-9][0-9]//g' \ -e 's/x2[0-5][0-9]//g'` echo "$RemovedHexRecord" >> striped_hex_memo.tsv Anyone see why this is not working. I'm on version 10.1 Thanks for any info & help |
|
|||
|
Am 12.01.2007 18:23 schrieb ljungers@sbcglobal.net:
> Here is the code I'm using, but for some reason it is not striping/dropping > the hex characters in the desired range. Exam B0 not dropped. > > RemovedHexRecord=`echo $OrgRecord \ > | sed -e 's/x12[89]//g' \ > -e 's/x1[3-9][0-9]//g' \ > -e 's/x2[0-5][0-9]//g'` > > echo "$RemovedHexRecord" >> striped_hex_memo.tsv > > Anyone see why this is not working. Sure. Your script is not searching for and removing bytes in the hex range as you intended, but occurrences of the letter 'x' followed by a three-digit decimal number in the range 128-259. Try it for example with OrgRecord="blax234blux246bb" and see it return "blablubb" in $RemovedHexRecord. What you want is achieved more easily with the tr(1) command. Try something like RemovedHexRecord=`echo $OrgRecord | tr -d '\200-\377'` (untested). HTH Tilman -- Tilman Schmidt E-Mail: tilman@imap.cc Bonn, Germany - In theory, there is no difference between theory and practice. In practice, there is. |
|
|||
|
> What you want is achieved more easily with the tr(1) command.
> Try something like > > RemovedHexRecord=`echo $OrgRecord | tr -d '\200-\377'` > > (untested). > > HTH > Tilman > Thanks for the sugestion on the tr command, and I did try it the way you illustrated above. After the script runs I used GHex to check the file that was created and I still find hex characters that I am trying to delete, such as Hex B0, Octal 260 still in the file. Could it be the way the range is setup and is it a character or numeric octal code that is used for the range check. Thanks again |
|
|||
|
Am 13.01.2007 22:30 schrieb ljungers@sbcglobal.net:
>> Try something like >> >> RemovedHexRecord=`echo $OrgRecord | tr -d '\200-\377'` >> >> (untested). >> > Thanks for the sugestion on the tr command, and I did try it the way you > illustrated above. After the script runs I used GHex to check the file that > was created and I still find hex characters that I am trying to delete, > such as Hex B0, Octal 260 still in the file. Hm, works for me: ts@gx110:~> echo $LANG de_DE@euro ts@gx110:~> OrgRecord=blabläblüblu ts@gx110:~> RemovedHexRecord=`echo $OrgRecord | tr -d '\200-\377'` ts@gx110:~> echo $RemovedHexRecord blablblblu ts@gx110:~> echo $OrgRecord | od -t x1 0000000 62 6c 61 62 6c e4 62 6c fc 62 6c 75 0a 0000015 ts@gx110:~> echo $RemovedHexRecord | od -t x1 0000000 62 6c 61 62 6c 62 6c 62 6c 75 0a 0000013 ts@gx110:~> Could you post your entire script? Perhaps the reason for it not working is to be found elsewhere than in the snippet you posted. -- Tilman Schmidt E-Mail: tilman@imap.cc Bonn, Germany - In theory, there is no difference between theory and practice. In practice, there is. |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|