Replace all 'low values" in a file


 
Thread Tools Search this Thread
Operating Systems HP-UX Replace all 'low values" in a file
# 1  
Old 06-21-2010
Replace all 'low values" in a file

Hi,

I've to replace all low values (hex '00') in a flat file (containing more than 1,000,000 records) with space (hex '20').
I try to use:

Code:
awk '{gsub("\x00","\x20")}' file_name

and I obtain the following response:

Code:
awk: Line AP000010536900577986 cannot have more than 199 fields.
The input line number is 1. The file is file_name.
The source line number is 1.

Can anyone help me?

Thanks in advance.

Stefano

Last edited by Scott; 06-21-2010 at 12:45 PM.. Reason: Please use code tags
# 2  
Old 06-21-2010
Quote:
Originally Posted by sw.an
Hi,

I've to replace all low values (hex '00') in a flat file (containing more than 1,000,000 records) with space (hex '20').
I try to use:

Code:
awk '{gsub("\x00","\x20")}' file_name

and I obtain the following response:

Code:
awk: Line AP000010536900577986 cannot have more than 199 fields.
The input line number is 1. The file is file_name.
The source line number is 1.

Can anyone help me?

Thanks in advance.

Stefano

It looks like your input file is all one "line", and there's a hard limit in awk for the number of fields (space separated since that's the default behavior without '-F' being used with awk).

I imagine that sed, being stream oriented, won't have this issue, so I'd try

Code:
sed -e 's/\x00/\x20/g'  input

and see what you get.
# 3  
Old 06-21-2010
Thanks a lot! Your command works well!

In the meanwhile I'd transformed my flat file in a text file (with cr+lf), where one record is 1500 chars long.

In this instance I'd like to use the awk command, but I obtain the same results (note that your suggestion works even in this case...). It's only to understand where I made an error.

Thanks a lot.

Stefano
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

2. Shell Programming and Scripting

How to delete a columns of a CSV file which has cell values with a string enclosed in " , "?

Hi How can I delete a columns from a CSV file which has comma separated value with a string enclosed in double quotes or square bracket and a comma in between? I have a csv file with below format. Template,Target Server,Target Component,Rule Group,Rule,Rule Reference Number,Rule... (7 Replies)
Discussion started by: Litu19
7 Replies

3. Shell Programming and Scripting

How to delete a column/columns of a CSV file which has cell values with a string enclosed in " , "?

How can I delete a column from a CSV file which has comma separated value with a string enclosed in double quotes and a comma in between? I have a file 44.csv with 4 lines including the header like the below format: column1, column2, column3, column 4, column5, column6 12,455,"string with... (6 Replies)
Discussion started by: dhruuv369
6 Replies

4. Shell Programming and Scripting

How to replace quote symbol(") and dot(.) with some other values!!

Hi , I have below input file 1.order number is useful. 2.vendor_id is produced. 3.the vandor name is "malawar". I want output file like 1. order number is useful. 2. vendor_id is produced. 3. the vandor name is VmalawarV. in input file line number 1.order number there is no... (4 Replies)
Discussion started by: vinothsekark
4 Replies

5. AIX

High Runqueue (R) LOW CPU LOW I/O Low Network Low memory usage

Hello All I have a system running AIX 61 shared uncapped partition (with 11 physical processors, 24 Virtual 72GB of Memory) . The output from NMON, vmstat show a high run queue (60+) for continous periods of time intervals, but NO paging, relatively low I/o (6000) , CPU % is 40, Low network.... (9 Replies)
Discussion started by: IL-Malti
9 Replies

6. Shell Programming and Scripting

Shell command to convert low values to spaces

I neead a script which converts low values to the spaces, When I used sed -e 's/\x00/\x20/g' inputfile command it is removing the low values but not replacing it with spaces. Please help me. Its Uregent. Thanks Sam (12 Replies)
Discussion started by: bsreee35
12 Replies

7. UNIX for Dummies Questions & Answers

replace "," with "." only in specific columns of a file?

Hi all, I have this text file containing 9 columns separated by space. The 8th columns contains the numbers. C1 C2 C3 C4 C5 C6 C7 C8 C9 er rt yt gh iu nk il 0.07 xs yt lr ty bg iu zk nh 0,0005 lt ...etc. I want to replace the comma with full stop only in 8th coloumn. the output... (8 Replies)
Discussion started by: Unilearn
8 Replies

8. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

9. Shell Programming and Scripting

Identify high values "ÿ" in a text file using Unix command

I have high values (such as ÿÿÿÿ) in a text file contained in an Unix AIX server. I need to identify all the records which are having these high values and also get the position/column number in the record structure if possible. Is there any Unix command by which this can be done to : 1.... (5 Replies)
Discussion started by: devina
5 Replies

10. Shell Programming and Scripting

low & high values

on the file Ftp'd from the mainframe ,do we have any UNIX command to replace mainframe low and values to space or null. i tried using tr and it doesn't work ... Thanks (1 Reply)
Discussion started by: rlmadhav
1 Replies
Login or Register to Ask a Question