Sponsored Content
Top Forums Shell Programming and Scripting Add 0 values to replace empty value Post 302803219 by anbu23 on Monday 6th of May 2013 08:14:47 AM
Old 05-06-2013
Code:
awk ' { printf("%s%06d%s\n", substr($0,1,120), substr($0,121,6), substr($0,127)) } ' file

This User Gave Thanks to anbu23 For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

use awk to replace empty fields with the latest nonempty field

Hi suppose I have a csv file like this count,1977,1978,1979 usa, , , blue japan, red, yellow,green india, , yellow,blue china, blue, yellow, green I want the output to be(replace everything, including empty data, with the most recent data): ... (1 Reply)
Discussion started by: grossgermany
1 Replies

2. Shell Programming and Scripting

how to add empty filed to record

hi i have record looks like below 1,US I want to add empty field to the record as below 1, , , ,US how i can do it using awk ? i tried with awk its not working awk '{ print $1", ,"$2 }' filename > file 1 (2 Replies)
Discussion started by: raghavendra.cse
2 Replies

3. Shell Programming and Scripting

Replace all found files with an empty file?

Hi all, I need to replace certain robots.txt files with an empty file. I use the following to find the files I want to empty out: find /Sites -type f -name "robots.txt" -exec grep -il "STAGE" {} \; (finds all robots.txt files which contain the string 'STAGE') Now what do I add to this... (3 Replies)
Discussion started by: Evert
3 Replies

4. Shell Programming and Scripting

Help needed :Search and Replace a string pattern with empty in an xml file in unix

Search and Replace a string pattern with empty in an xml file in unix: My xml file would be like this : <Accounts><Name>Harish</Name><mobile>90844444444444445999 </mobile><TRIG>srcujim-1</TRIG></Accounts><Accounts><Name>Satish</Name><mobile>908999</mobile><TRIG>ettertrtt-1</TRIG></Accounts> ... (1 Reply)
Discussion started by: harish_s_ampeo
1 Replies

5. Shell Programming and Scripting

Replace empty string on particular column

Hi I would like to replace empty string with a particluar value, any suggessions with awk ? my input file is not delimited with any delimiters input 52001073M8000000004567777 5200107 000000004567778 5200107 000000004567779 52001073M8000000004567789 Expected output... (5 Replies)
Discussion started by: selvankj
5 Replies

6. Shell Programming and Scripting

Replace space with empty

Hi All, My Input is: 111.121 23212121 121.231 12678878 My output should be 111.12123212121 121.23112678878 in each row i need to replace that perticular space with empty. 8th position in the file for all rows. Please help me in this case .. Thanks (7 Replies)
Discussion started by: raju4u
7 Replies

7. Shell Programming and Scripting

Need command to replace empty using sed/awk

Hi, In a file we have the following data like as below abcdef="cfg-1-15" bmmdda-g-45-2 yhdiao"rtg-1-df-34" I need a sed/awk command to replace the above string with empty. Thx, (1 Reply)
Discussion started by: kirankumar
1 Replies

8. Shell Programming and Scripting

Replace values

Gents, Please can you help me with this. When column 49 == 2 Need to do the following changes; Change previous row field (substr$0,45,4)-1 Change previous row field (substr$0,72,5)+2 Change actual row field (substr$0,40,4)+1 Change actual row field (substr$0,49,1)-1 Change actual... (6 Replies)
Discussion started by: jiam912
6 Replies

9. Shell Programming and Scripting

Replace values

Gents, Can you please help with this. Input file 49955 2009 2 49957 2010 2 49959 2010 2 49961 2010 2 49963 2010 2 49789 2011 -174 49791 2011 2 49793 2011 2 49795 2011 2 49965 2011 170 49967 2011 2 49969 2011 2 49971 2011 2 49797 2012 -174 49799 2012 2 (8 Replies)
Discussion started by: jiam912
8 Replies
bytes(3pm)						 Perl Programmers Reference Guide						bytes(3pm)

NAME
bytes - Perl pragma to force byte semantics rather than character semantics NOTICE
This pragma reflects early attempts to incorporate Unicode into perl and has since been superseded. It breaks encapsulation (i.e. it exposes the innards of how the perl executable currently happens to store a string), and use of this module for anything other than debugging purposes is strongly discouraged. If you feel that the functions here within might be useful for your application, this possibly indicates a mismatch between your mental model of Perl Unicode and the current reality. In that case, you may wish to read some of the perl Unicode documentation: perluniintro, perlunitut, perlunifaq and perlunicode. SYNOPSIS
use bytes; ... chr(...); # or bytes::chr ... index(...); # or bytes::index ... length(...); # or bytes::length ... ord(...); # or bytes::ord ... rindex(...); # or bytes::rindex ... substr(...); # or bytes::substr no bytes; DESCRIPTION
The "use bytes" pragma disables character semantics for the rest of the lexical scope in which it appears. "no bytes" can be used to reverse the effect of "use bytes" within the current lexical scope. Perl normally assumes character semantics in the presence of character data (i.e. data that has come from a source that has been marked as being of a particular character encoding). When "use bytes" is in effect, the encoding is temporarily ignored, and each string is treated as a series of bytes. As an example, when Perl sees "$x = chr(400)", it encodes the character in UTF-8 and stores it in $x. Then it is marked as character data, so, for instance, "length $x" returns 1. However, in the scope of the "bytes" pragma, $x is treated as a series of bytes - the bytes that make up the UTF8 encoding - and "length $x" returns 2: $x = chr(400); print "Length is ", length $x, " "; # "Length is 1" printf "Contents are %vd ", $x; # "Contents are 400" { use bytes; # or "require bytes; bytes::length()" print "Length is ", length $x, " "; # "Length is 2" printf "Contents are %vd ", $x; # "Contents are 198.144" } chr(), ord(), substr(), index() and rindex() behave similarly. For more on the implications and differences between character semantics and byte semantics, see perluniintro and perlunicode. LIMITATIONS
bytes::substr() does not work as an lvalue(). SEE ALSO
perluniintro, perlunicode, utf8 perl v5.12.1 2010-04-26 bytes(3pm)
All times are GMT -4. The time now is 03:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy