Convert Char to Dec using AWK


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Convert Char to Dec using AWK
# 1  
Old 06-09-2005
Convert Char to Dec using AWK

I'm facing a problem when trying to read a file and convert the content from char to decimal in ASCII. Smilie

eg :-
Input file :
20051231 8.00

experted result :
50484853495051493256464848

The content of input file is vary very day.
I need to use AWK script to program it.
Pls help. TQ....
# 2  
Old 06-09-2005
I suggest using od instead of awk.
# 3  
Old 06-09-2005
I have try but not the result i want!!
$)cat a
20051231 8.00

When I try as below:-
$)od -d a
0000000 12848 12341 12594 13105 08248 11824 12298
0000016

any other command can use?
# 4  
Old 06-09-2005
Code:
od -A n -t u1 <urfile>

Quote:
od --version
od (coreutils) 5.0
Written by Jim Meyering.
# 5  
Old 06-09-2005
ok i get it.
TQ.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to convert dec to hex in python?

When I try to convert big numbers I get extra numbers at the end that doesn't move plus an L character too. How to remove the 4 extra characters at the end 000L? 8b8dbbc584d9c000L 8b8dc4ddd34c6000L 8b8dcdf621bf0000L 8b8dd70e7031a000L 8b8de026bea44000L #!/usr/bin/python ... (9 Replies)
Discussion started by: bigvito19
9 Replies

2. Shell Programming and Scripting

awk pad 1 column with leading zero if char > 12

Hello, I got a question. I have several csv files with lots of data in it and for the first column i have EAN codes. The problem that i am facing is that some of these codes have the leading 0 removed so they are 12 or less chars while a EAN code is (always?) 13 chars. For this i used a... (9 Replies)
Discussion started by: SDohmen
9 Replies

3. Shell Programming and Scripting

Awk, function of underscore char.

Hello Friends, I would appreciate so much if you could explain how the underscores works at the following code? Sorry if it sounds a bit novice question. awk -F',' 'NR==FNR{_=1;next}!_{print}' exclude infile KR, Eagle (6 Replies)
Discussion started by: EAGL€
6 Replies

4. UNIX for Dummies Questions & Answers

AWK - changing first char from small to upper

I need to write script in AWK, changing first char from a line from lower to upper. I found function toupper etc. but have no idea how to sent only first char from every line instead of the whole line. Anyone has any idea? // Sorry for my english:D (8 Replies)
Discussion started by: bbqtoss
8 Replies

5. Programming

AWK char '

Is it possibile to change char ' to another with awk? (2 Replies)
Discussion started by: MSMario
2 Replies

6. Shell Programming and Scripting

can I remove the first char using AWK?

Hi everyone, suppose that I have the following line: #test your knowledge can I use AWK to print the word "test" only? without the #? what should I change to this: awk '{print $1}' thanks in advance guys (2 Replies)
Discussion started by: Abdulelah
2 Replies

7. Shell Programming and Scripting

need to convert a decimal value to an ascii char with awk for the field delimiter

Hello, I need an awk script to receive a variable that's an decimal value such as 009 or 031 and then convert this value to an ascii character to use as the FS (field separator for the input file). For example, 009 should be converted to an ascii tab 031 should be converted to an ascii... (1 Reply)
Discussion started by: script_op2a
1 Replies

8. 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

9. Shell Programming and Scripting

Substitution of char with AWK

I created a file contains: create table .....; create index ....; create trigger...; and I want to substitue from my file ; by ;-- from the line where appears create trigger to the end of the file and keep intact the create table step and index in the file. awk '/CREATE... (2 Replies)
Discussion started by: mario dionne
2 Replies

10. Shell Programming and Scripting

how to convert char to num

how to convert char to num or visa versa i am a beginner how to do it can someone guide me please (2 Replies)
Discussion started by: guhas
2 Replies
Login or Register to Ask a Question