Sponsored Content
Top Forums Shell Programming and Scripting Replace nulls with a value in a file Post 302852127 by Jotne on Tuesday 10th of September 2013 03:02:30 PM
Old 09-10-2013
Code:
awk -F\| '$4=="" {$4=$2}1' OFS=\| file
ABCD|X-TYPE 3.0|2010|X-TYPE|20000
CDEF|C-TYPE 2.5|2011|C-TYPE|10000
XYZ|LX 4WD|2009|LX|20000
PQR|EX 4WD|2009|EX 4WD|20000

Code:
awk -F\| '$4=="" {split($2,a," ");$4=a[1]}1' OFS=\| file
ABCD|X-TYPE 3.0|2010|X-TYPE|20000
CDEF|C-TYPE 2.5|2011|C-TYPE|10000
XYZ|LX 4WD|2009|LX|20000
PQR|EX 4WD|2009|EX|20000

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

GREPing for Nulls

I just had a filesystem / file corruption issue on my HSP's server due to disk capacity limits and fileswapping. I discovered that certain files got corrupted when fileswapping was not successful and they ended up with a string of control characters, or what I believe to be nulls, in them. Does... (4 Replies)
Discussion started by: Dr. DOT
4 Replies

2. Programming

Blanks vs: Nulls

I'm relatively new to Pro*C programming. In the following example: char name; EXEC SQL SELECT 'John Doe' INTO :name FROM DUAL; "John Doe" is in positions 0-7, blanks in 8-19, and a null in 20. I would really prefer the null to be in position 8 and I don't care what's after that. I wrote a... (1 Reply)
Discussion started by: ebock
1 Replies

3. Shell Programming and Scripting

Replacing nulls using sed

Hi, I am trying to replace nulls with spaces in every record of a '|' delimited file. I used this command - cat input.dat | sed 's/||/| |/g' > output But if a space appears twice '| | |' , then only the first null is getting replaced with a space. The second one remains as a null. I... (7 Replies)
Discussion started by: novice1324
7 Replies

4. Shell Programming and Scripting

How to check Null values in a file column by column if columns are Not NULLs

Hi All, I have a table with 10 columns. Some columns(2nd,4th,5th,7th,8th and 10th) are Not Null columns. I'll get a tab-delimited file and want to check col by col and generate seperate error code for each col eg:102 if 2nd col value is NULL and 104 if 4th col value is NULL so on... I am a... (7 Replies)
Discussion started by: Mandab
7 Replies

5. Shell Programming and Scripting

sort truncates line when they contain nulls

When I try to sort a file where some records contain nulls i.e. hex 00 the sort truncates the record when it reaches the null and writes message: "sort: warning: missing NEWLINE added at end of input file myfile" I'm assuming from this that the sort sees the null as a special character and... (6 Replies)
Discussion started by: ArthurWaik
6 Replies

6. Shell Programming and Scripting

replace nulls with whitespaces in a file

Hi, i have a file which contains data in fixed length. each row contains data of 10 characters fixed length. The data in the file appears like 4567782882 some times i may recieve dat less than fixed length of 10. in such a case i find nulls appended at the trailing spaces when i do a... (2 Replies)
Discussion started by: meeragiri
2 Replies

7. Red Hat

Counting columns in a delimited record with NULLs

I am trying to count the number of columns in a delimited flat file. The record is tab delimited. When I use the command wc -w, I am getting unexpected results when the record contains a NULL value. I believe it is because there is a "word" missing. The below example will return 4 words... (2 Replies)
Discussion started by: nmalencia
2 Replies

8. Shell Programming and Scripting

Script that Nulls Contents of Files

Ok, I'm stuck here with a plan to get what I need done completed. I want to use perl to produce a document. lets say the document will be a pdf document. Now, is there a way for me to put a tiny little code in that pdf document that can make the pdf file null itself if run on a non-unix... (2 Replies)
Discussion started by: SkySmart
2 Replies

9. UNIX for Beginners Questions & Answers

Remove or truncate trailing nulls from file

I want to remove from a file the trailing null characters (0x00) and stop doing so when a different byte is found (which should not be deleted), and either put the result to the same file or a different one. Any ideas? (9 Replies)
Discussion started by: Tribe
9 Replies
HTTP_THROTTLE(3)							 1							  HTTP_THROTTLE(3)

http_throttle - HTTP throttling

SYNOPSIS
void http_throttle (float $sec, [int $bytes = 40960]) DESCRIPTION
Sets the throttle delay and send buffer size. Note This function should be used in conjunction with http_send_data(3), http_send_file(3) and http_send_stream(3). Note Provides a basic throttling mechanism, which will yield the current process or thread until the entity has been completely sent. Note This may not work as expected with the following SAPI(s): FastCGI. PARAMETERS
o $sec - seconds to sleep after each chunk sent o $bytes - the chunk size in bytes EXAMPLES
Example #1 A http_throttle(3) example Send file with approximately 20 kbyte/s. <?php // ~ 20 kbyte/s # http_throttle(1, 20000); # http_throttle(0.5, 10000); http_throttle(0.1, 2000); http_send_file('document.pdf'); ?> SEE ALSO
http_send_data(3), http_send_file(3), http_send_stream(3), the HttpResponse class if you are using PHP 5.1.0 and above. PHP Documentation Group HTTP_THROTTLE(3)
All times are GMT -4. The time now is 03:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy