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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need to convert a decimal value to an ascii char with awk for the field delimiter
# 1  
Old 12-06-2010
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 Unit Separator

awk -v delimiter="031" '
BEGIN {
FS=delimiter;

} # end BEGIN
{

}
END{

}' <infile >outfile
# 2  
Old 12-06-2010
use awk to get the value to use for awk Smilie

Code:
delim=`echo "009" | awk '{printf("%c", $0);}'`


awk -F "${delim}" ...etc...

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert Hexdecimal to Decimal in Solaris awk

Hi there, i want to use this Linux-script on a Solaris System to check the fragmentation Level of ZFS-DataSets: #!/bin/sh zdb -ddddd ${1} | awk --non-decimal-data \ ' /Indirect blocks/ { file_number++; next_block = 0; } /L0/ { split($3, fields, ":"); this_block =... (10 Replies)
Discussion started by: Ragesm
10 Replies

2. UNIX for Beginners Questions & Answers

String has * as the field delimiter and I need echo/awk to escape it, how?

Hi, I am trying to read an Oracle listener log file line by line and need to separate the lines into several fields. The field delimiter for the line happens to be an asterisk. I have the script below to start with but when running it, the echo command is globbing it to include other... (13 Replies)
Discussion started by: newbie_01
13 Replies

3. Shell Programming and Scripting

How can awk ignore the field delimiter like comma inside a field?

We have a csv file as mentioned below and the requirement is to change the date format in file as mentioned below. Current file (file.csv) ---------------------- empname,date_of_join,dept,date_of_resignation ram,08/09/2015,sales,21/06/2016 "akash,sahu",08/10/2015,IT,21/07/2016 ... (6 Replies)
Discussion started by: gopal.biswal
6 Replies

4. Programming

Urgent help needed.. C++ program to convert decimal to hexa decimal

Hi , seq can be 0...128 int windex = seq / 8; int bindex = seq % 8; unsigned char bitvalue = '\x01' << (7-bindex) ; bpv.bitmapvalue = bitvalue; This is the part of a program to convert decimal to bitmap value of hexadecimal. I want this to change to convert only to... (1 Reply)
Discussion started by: greenworld123
1 Replies

5. Shell Programming and Scripting

awk :how to change delimiter without giving all field name

Hi Experts, i need to change delimiter from tab to "," sample test file cat test A0000368 A29938511 072569352 5 Any 2 for Ģ1.00 BUTCHERS|CAT FOOD|400G Sep 12 2012 12:00AM Jan 5 2014 11:59PM Sep 7 2012 12:00AM M 2.000 group 5 ... (2 Replies)
Discussion started by: Lakshman_Gupta
2 Replies

6. Shell Programming and Scripting

awk output field delimiter

Dear All, 1.txt (tab in between each value in a line) a b c a b c a c d you can see below, why with ~ i can output with tab, but = cannot? # awk -F'\t' '$2 ~ /b/' 1 a b c a b c # awk -F'\t' '$2 = "b"' 1 a b c a b c a b d ... (1 Reply)
Discussion started by: jimmy_y
1 Replies

7. UNIX for Advanced & Expert Users

Printing Field with Delimiter in AWK/cut

Hello, I had posted earlier about printing fields using AWK, but now I have a slightly different problem. I have text files in the format: 1*2,3,4,5 and wish to print the first, third, and fifth fields, including the asterisk and commas. In other words, after filtering it should look... (1 Reply)
Discussion started by: Jahn
1 Replies

8. Shell Programming and Scripting

how to convert data from ASCII to Packed Decimal

Hi All, Please let me know if it is possible to convert data from ASCII to Packed Decimal through Unix? Basically we have ASCII file with numeric data we want to convert that files data to Packed decimal format to send it to main frame. Please let me know if we can do it through unix script.... (1 Reply)
Discussion started by: aloktiwary
1 Replies

9. Shell Programming and Scripting

Set a variable field delimiter using awk

How can i set a variable field delimiter using awk?? I wanna do something like this ,but i canīt get the correct syntaxis : VARI=TEST echo "0121212TESTxvcshaashd"|awk 'FS="$VARI" {print $2}' Thanks. (2 Replies)
Discussion started by: Klashxx
2 Replies

10. Shell Programming and Scripting

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. :confused: 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... (4 Replies)
Discussion started by: jasmine05
4 Replies
Login or Register to Ask a Question