Sponsored Content
Top Forums Shell Programming and Scripting Convert hex values to displayable characters Post 302472541 by methyl on Wednesday 17th of November 2010 11:24:27 AM
Old 11-17-2010
What unix Operating System are you running?

Assuming that this is a text file containing only characters data and was written on something like an IBM mainframe, the general solution is to use unix "dd" command with the "conv=ascii" parameter. Search for "conv=ascii" on this board.
In general this sort of conversion is best done at source because record structure and end-of-file can be lost during transmission.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

convert hex to ascii text

Is there a command to convert hex characters into their respective ascii values? (5 Replies)
Discussion started by: dangral
5 Replies

2. Programming

to convert int to hex

Hi, Can you help me in converting int value to hex in a single command. Thanks (8 Replies)
Discussion started by: naan
8 Replies

3. Shell Programming and Scripting

How to Convert Hex value to Dec ?

Hi All, I want to convert below Hex value to Dec value in each column .How to do it ? This data is in a 1 file. 4e20 0475 2710 010f 7530 69a2 7530 7e2f 4e20 02dd 7530 6299 4e20 0c0a 7530 69a2 4e20 0a0b 2710 0048 7530 7955 4e20 0d23 7530 622d 7530 9121 2710 001f 7530 7d3f (6 Replies)
Discussion started by: Nayanajith
6 Replies

4. Programming

Convert HEX to EBCDIC IN C

i want to convert Hex value To EBCDIC value. i tried to convert hex to ascii and then to ebcdic but it doesn't give desired results . it doesn't give corresponding ebcdic value instead it gives some junk values. e.g; Hex EBCDIC ----------------- 81 a 82 b 83 c 84 d 85 e 86 f 87... (6 Replies)
Discussion started by: junaid.nehvi
6 Replies

5. Shell Programming and Scripting

convert ascii values into ascii characters

Hi gurus, I have a file in unix with ascii values. I need to convert all the ascii values in the file to ascii characters. File contains nearly 20000 records with ascii values. (10 Replies)
Discussion started by: sandeeppvk
10 Replies

6. Shell Programming and Scripting

Convert hex to decimal or reverse is better?

Please Help Me! about the problem down under. I have 2 files with nearly the same characteristics, I have to convert one to the other format or the other format to one's format. I want to write it with awk. The first file contain lines like this: 300000001#A#Y#Y#Y#Y The other file contain... (4 Replies)
Discussion started by: Axel82
4 Replies

7. Shell Programming and Scripting

Convert Hex - KSH

Hello, I woild like to convert hex on KSH not BASH: I tried to use: tmp=31 printf "\x"${tmp}"" it works on bash - Output is '1' but not on ksh. please advice on the right syntax. Thanks. (4 Replies)
Discussion started by: LiorAmitai
4 Replies

8. Shell Programming and Scripting

Convert to Hex in perl

Hi, i want to convert number 5860533159 to hexadecimal. i need to use perl. i used $foo = 5860533159; $hexval3 = sprintf("%#x", $foo); i am getting value as 0xffffffff. i need to get value as 0x15D50A3A7. when i converted using google calculator, i got the correct value, expected... (9 Replies)
Discussion started by: asak
9 Replies

9. Shell Programming and Scripting

Convert hex to decimal

can someone help me in converting hex streams to decimal values using perl script Hex value: $my_hex_stream="0c07ac14001676"; Every hex value in the above stream should be converted in to decimal and separated by comma. The output should be: 12,07,172,20,00,22,118 (2 Replies)
Discussion started by: Arun_Linux
2 Replies

10. 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
dd(1)							      General Commands Manual							     dd(1)

NAME
dd - Converts and copies a file SYNOPSIS
dd [option=value...] STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: dd: XCU5.0, SVID 4 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
None OPERANDS
The option=value operand set may take any of the following forms: Specifies the input file name; standard input is the default. Specifies the output file name; standard output is the default. For the above operands, the application must supply an expression specifying a size in bytes. The expression, expr can be: a positive decimal number a positive decimal number followed by k specifying mutiplication by 1024 a positive decimal number followed by b specifying multiplication by 512 two or more positive decimal numbers with or without k or b seper- ated by x, specifying the product of the indicated values. All the operands will be processed before any input is read. Skips number input records before starting copy. [Tru64 UNIX] Copies number input files before terminating (makes sense only where input is a magnetic tape or similar device). [Tru64 UNIX] Seeks to the numberth record from the beginning of input file before copying. [Tru64 UNIX] Seeks to the numberth record from the beginning of output file before copying. Same as seek=number. Seeks to the numberth record from the beginning of output file before copying. Same as oseek=number. Copies only number input records. Specifies one or more of the following conversions: Converts EBCDIC to ASCII. Converts variable-length records to fixed-length. Converts ASCII to EBCDIC. Converts IBM-EBCDIC to ASCII. Performs a slightly different map of ASCII to EBCDIC. Converts fixed-length records to variable-length. Makes all alphabetic characters lower case. Makes all alphabetic characters upper case. Swaps every pair of bytes. Does not stop processing on an error. Pads every input record to ibs. [Tru64 UNIX] Creates a sparse output file as described in AdvFS Administration. Do not truncate the output file. Preserve blocks in the output file not explicitly written by this invocation of the dd utility. (See the of=output_file oper- and.) Allows several comma-separated conversions. DESCRIPTION
The dd command reads the specified input file or standard input, does the specified conversions, and copies it to the specified output file or standard output. The input and output block size may be specified to take advantage of raw physical I/O. The terms block and record refer to the quantity of data read or written by dd in one operation and are not necessarily the same size as a disk block. Where sizes are specified, a number of bytes is expected. A number may end with w, b, or k to specify multiplication by 2, 512, or 1024, respectively; a pair of numbers can be separated by an x to indicate a product. The cbs specification is used if one of the following conversions is specified: ascii, unblock, ebcdic, ibm, or block. For the first two conversions, dd places characters in a conversion buffer of size cbs, converts these characters to ASCII, trims trailing spaces, and adds newline characters before sending data to the specified output. For the latter three cases, dd places ASCII characters in the conversion buffer, converts these characters to EBCDIC, and adds trailing spaces to create an output record of size cbs. After it finishes, dd reports the number of whole and partial input and output blocks. NOTES
[Tru64 UNIX] To copy to a raw disk, the disk label must first be zeroed using the disklabel -z command. For example: disklabel -z disk/cdrom17 [Tru64 UNIX] If you do not zero out the disk label, dd fails with the following error message: dd write error: Read-only file sys- tem The ASCII/EBCDIC conversion tables are taken from the 256 character standard in the CACM November, 1968. There is no universal standard for EBCDIC/ASCII translation. [Tru64 UNIX] One must specify conv=noerror,sync when copying raw disks with bad sectors to ensure dd stays synchronized. [Tru64 UNIX] Certain combinations of arguments to conv= are permitted. However, the block or unblock option cannot be combined with ascii, ebcdic, or ibm. Invalid combinations silently ignore all but the last mutually exclu- sive keyword. [Tru64 UNIX] If you need to use dd to copy to a streaming tape and the data is an odd length (not a multiple of 512 bytes), you must use the conv=sync flag to fill the last record. Streaming tape devices permit only multiples of 512 bytes. [Tru64 UNIX] If option bs is used (or bs is equal to obs) and no conversion is specified, then dd is particularly efficient since less memory copies are done. [Tru64 UNIX] The dd command does not support floppy disk multivolumes, but it does support tape multivol- umes. This means that when ENOSPC is returned while reading or writing a tape, dd will prompt the user for a new tape. [Tru64 UNIX] In order to make use of tape multivolumes, the files option must be used. Security Note [Tru64 UNIX] Any file system archive that contains ACLs (access control lists) that was created using dd is not exportable unless the tar- get system has the exact same password and group files. If there is a mismatch, incorrect access may be granted to a file or directory. EXIT STATUS
The following exit values are returned: The input file was successfully copied. An error occurred DIAGNOSTICS
This message specifies the number of full and partial records both read and written: f+p records in f+p records out The number of full records read or written (f) refers to the blocks of data of size ibs or obs. The number of partial records read or written (p) refers to the blocks of data smaller than ibs or obs. EXAMPLES
To read an EBCDIC tape blocked ten 80-byte EBCDIC card images per record into the ASCII file x, enter: dd if=/dev/tape/tape0_d0 of=x ibs=800 cbs=80 conv=ascii,lcase Note the use of raw magnetic tape. The dd command is especially suited to I/O on the raw physical devices because it allows reading and writing in arbitrary record sizes. To convert an ASCII text file to EBCDIC, enter: dd if=text.ascii of=text.ebcdic conv=ebcdic This converts text.ascii to EBCDIC representation, storing this in text.ebcdic. ENVIRONMENT VARIABLES
The following environment variables affect the execution of dd: Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari- ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale for the for- mat and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. SEE ALSO
Commands: cp(1), cpio(1), sed(1), tar(1), tr(1), trbsd(1) Functions: lseek(2) Routines: fseek(3) Files: ascii(5) Standards: standards(5) Command and Shell User's Guide AdvFS Administration dd(1)
All times are GMT -4. The time now is 01:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy