Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Replace a numeric values in a certain column Post 303031042 by RavinderSingh13 on Wednesday 20th of February 2019 10:20:41 PM
Old 02-20-2019
Hello arunkumar_mca,

Could you please try following once. This is specifically for 35th character's replacement.
I am using substring function of awk to get first 34 characters and then printing 7 along with rest of the characters of line.

Code:
awk '{print substr($0,1,34) "7" substr($0,36)}'  Input_file

Thanks,
R. Singh
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace spaces with 0's having numeric values.

What could be the regular expression with gsub function in awk to replace all numerics having spaces before to be replaced with 0s? (1 Reply)
Discussion started by: videsh77
1 Replies

2. UNIX for Advanced & Expert Users

replace a column values with the first value in column

Hi All, I have a file which has data in following format: "Body_Model","2/1/2007","2/1/2007" "CSCH74","0","61" "CSCS74","0","647" "CSCX74","0","3" "CSYH74","0","299" "CSYS74","0","2514" "CSYX74","0","3" "Body_Model","3/1/2007","3/1/2007" "CSCH74","0","88" "CSCS74","0","489"... (3 Replies)
Discussion started by: sumeet
3 Replies

3. Shell Programming and Scripting

replace the column values.

I have the below file ...where some of the column values should replaced with desired values ....below file u can find that 3 column where ever 'AAA' comes should replaced with ' CC ' NOTE : we have to pass the column number ,AAA,CC (modified value) as the parameters to the code. ... (6 Replies)
Discussion started by: charandevu
6 Replies

4. UNIX for Dummies Questions & Answers

Find and Replace random numeric value with non-numeric value

Can someone tell me how to change the first column in a very large 17k line file from a random 10 digit numeric value to a non numeric value. The format of lines in the file is: 1702938475,SNU022,201004 the first 10 numbers always begin with 170 (6 Replies)
Discussion started by: Bahf1s
6 Replies

5. UNIX for Dummies Questions & Answers

Replace values in a specified column of a file

Hello, I have a file with four columns and I would like to replace values in the second column only. An arbitrary example is: 100 A 105 B 200 B 205 C 300 C 305 D 400 D 405 E 500 E 505 F I need to replace the second column as shown below: ... (4 Replies)
Discussion started by: Gussifinknottle
4 Replies

6. UNIX for Dummies Questions & Answers

replace a column with values from another file

Dear all, I have a file1.pdb in pdb format and a dat file2 containing values, corresponding to the atoms in the pdb file. these values (file2.dat) need to be in the column instead of the 0.00 (file1) values for each atom in file1.pdb .(the red values must be replaced by the blue ones,in order)... (11 Replies)
Discussion started by: chen.xiao.po
11 Replies

7. Shell Programming and Scripting

Splitting the numeric vs alpha values in a column to distinct columns

How could i take an input file and split the numeric values from the alpha values (123 vs abc) to distinc columns, and if the source is blank to keep it blank (null) in both of the new columns: So if the source file had a column like: Value: |1 | |2.3| | | |No| I would... (7 Replies)
Discussion started by: driftlogic
7 Replies

8. Shell Programming and Scripting

Replace column values from other file

I have one file as it has the following format File1 S No Site IP Address 1 Australia 192.168.0.1/26 2 Australia 192.168.0.2/26 3 Australia 192.168.0.3/26 I need awk/sed command to replace the column2 value ( under Site) with some other... (8 Replies)
Discussion started by: samaritan
8 Replies

9. UNIX for Dummies Questions & Answers

Replace all decimal values in a column

Hi My input file looks String000002 GeneWise CW 48945 49354 . - 0 Pt=PEQU_00004; String000002 LEN NA 52125 52604 0.945751 - . PID=PEQU_00005;lvid_id=PEQ_28708; String000002 LEN CW 52125 52604 . - 0 ... (3 Replies)
Discussion started by: siya@
3 Replies

10. UNIX for Advanced & Expert Users

Sort by second column numeric values

From googling and reading man pages I figured out this sorts the first column by numeric values. sort -g -k 1,1 Why does the -n option not work? The man pages were a bit confusing. And what if I want to sort the second column numerically? I haven't been able to figure that out. The file... (7 Replies)
Discussion started by: cokedude
7 Replies
Text::Aligner(3pm)					User Contributed Perl Documentation					Text::Aligner(3pm)

NAME
Text::Aligner SYNOPSIS
use Text::Aligner qw( align); # Print the words "just a test!" right-justified each on a line: my @lines = align( 'right', qw( just a test!); print "$_ " for @lines; DESCRIPTION
Text::Aligner exports a single function, align(), which is used to justify strings to various alignment styles. The alignment specification is the first argument, followed by any number of scalars which are subject to alignment. The operation depends on context. In list context, a list of the justified scalars is returned. In scalar context, the justified arguments are joined into a single string with newlines appended. The original arguments remain unchanged. In void context, in-place justification is attempted. In this case, all arguments must be lvalues. Align() also does one level of scalar dereferencing. That is, whenever one of the arguments is a scalar reference, the scalar pointed to is aligned instead. Other references are simply stringified. An undefined argument is interpreted as an empty string without complaint. Alignment respects colorizing escape sequences a la Term::ANSICOLOR, which means it knows that thses sequences don't take up space on the screen. ALIGNMENT
The first argument of the align() function is an alignment style, a single scalar. It can be one of the strings "left", "right", "center", "num", "point", or "auto", or a regular expression (qr/.../), or a coderef. A default style of "left" is assumed for every other value, including "" and undef. "left", "right" and "center" have the obvious meanings. These can also be given as numbers 0, 1, and 0.5 respectively. (Other numbers are also possible, but probably not very useful). "num", and its synonym "point", specify that the decimal points be aligned (assumed on the right, unless present). Arbitrary (non-numeric) strings are also aligned in this manner, so they end up one column left of the (possibly assumed) decimal point, flush right with any integers. For the occasional string like "inf", or "-" for missing values, this may be the right place. A string-only column ends up right-aligned (unless there are points present). The "auto" style separates numeric strings (that are composed of "-", ".", and digits in the usual manner) and aligns them numerically. Other strings are left aligned with the number that sticks out farthest to the left. This gives left alignment for string-only columns and numeric alignment for columns of numbers. In mixed columns, strings are reasonably placed to serve as column headings or intermediate titles. With "num" (and "point") it is possible to specify another character for the decimal point in the form "num(,)". In fact, you can specify any string after a leading "(", and the closing ")" is optional. "point(=>)" could be used to align certain pieces of Perl code. This option is currently not available with "auto" alignment (because recognition of numbers is Anglo-centric). If a regular expression is specified, the points are aligned where the first match of the regex starts. A match is assumed immediately after the string if it doesn't match. A regular expression is a powerful way of alignment specification. It can replace most others easily, except center alignment and, of course, the double action of "auto". POSITIONERS
For entirely self-defined forms of alignment, a coderef, also known as a positioner, can be given instead of an alignment style. This code will be called once or more times with the string to be aligned as its argument. It must return two numbers, a width and a position, that describe how to align a string with other strings. The width should normally be the length of the string. The position defines a point relative to the beginning of the string, which is aligned with the positions given for other strings. A zero position for all strings results in left alignment, positioning to the end of the string results in right alignment, and returning half the length gives center alignment. "num" alignment is realized by marking the position of the decimal point. Note that the position you return is a relative measure. Adding a constant value to all positions results in no change in alignment. It doesn't have to point inside the string (as in right alignment, where it points one character past the end of the string). The first return value of a positioner should almost always be the length of the given string. It may be useful to ly about the string length if the string contains escape sequences that occupy no place on screen. USAGE
use Text::Aligner qw( align); align( $style, $str, ...); $style must be given and must be an alignment specification. Any number of scalars can follow. An argument that contains a scalar reference is dereferenced before it is used. In scalar and list context, the aligned strings are returned. In void context, the values are aligned in place and must be lvalues. BUGS
None known as of realease, but... AUTHOR
Anno Siegel CPAN ID: ANNO COPYRIGHT
Copyright (c) 2002 Anno Siegel. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. SEE ALSO
perl(1) Text::Table perl v5.10.1 2011-06-10 Text::Aligner(3pm)
All times are GMT -4. The time now is 06:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy