Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Replace specific positions in a file Post 303031524 by Akshay Hegde on Friday 1st of March 2019 02:05:03 PM
Old 03-01-2019
Here is a way to play with awk

Code:
akshay@db-3325:/tmp$ cat file
H0187459823 172SMITH, JOE
H0112345678 172DOE, JANE

akshay@db-3325:/tmp$ awk '{print substr($0,1,3)"<put_your_string>"substr($0,13)}' file
H01<put_your_string>172SMITH, JOE
H01<put_your_string>172DOE, JANE

These 2 Users Gave Thanks to Akshay Hegde For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace 9-16 positions of a text file.

Hi i am having text file like this 40000201040005200213072009000000700000050744820906904421 40069300240005200713072009000000067400098543630000920442 i want to replace 9-16 positions of my txt file...by 1234567...in a single line command i.e 0400052....should be replaced by... (2 Replies)
Discussion started by: suryanarayana
2 Replies

2. Shell Programming and Scripting

Need specific byte positions of a file

Hello , I need to extract data from specific byte positions of a file. I have tried the below command awk ' { printf "%s", substr($0, 642363,642369}' filename to extract data between byte positions 642363 and 642369 . However I did not get the expected result. I am new to awk... (6 Replies)
Discussion started by: rmv
6 Replies

3. Shell Programming and Scripting

awk script replace positions if certain positions equal prescribed value

I am attempting to replace positions 44-46 with YYY if positions 48-50 = XXX. awk -F "" '{if (substr($0,48,3)=="XXX") $44="YYY"}1' OFS="" $filename > $tempfile But this is not working, 44-46 is still spaces in my tempfile instead of YYY. Any suggestions would be greatly appreciated. (9 Replies)
Discussion started by: halplessProblem
9 Replies

4. Shell Programming and Scripting

Replace a string within a file.. with help of positions

I have a huge file with lot of rows... with each row around 400 characters.. with spaces as well.. (e.g) Line1: "AC254600606 USDMI000001Anom01130073981 0000000000000.002005040720991231 ... (13 Replies)
Discussion started by: gopeezere
13 Replies

5. Shell Programming and Scripting

output strings to specific positions in a file

Been searching for about 3 hours for similar functionality that I can get examples of how to output text from variables into certain locations in a file. I would like to incorporate this into a script. I have not been able to find a command example that does it all in one method. I find part of... (1 Reply)
Discussion started by: bennu_500
1 Replies

6. Shell Programming and Scripting

Count specific characters at specific column positions

Hi all, I need help. I have an input text file (input.txt) like this: 21 GTGCAACACCGTCTTGAGAGG 50 21 GACCGAGACAGAATGAAAATC 73 21 CGGGTCTGTAGTAGCAAACGC 108 21 CGAAAAATGAACCCCTTTATC 220 21 CGTGATCCTGTTGAAGGGTCG 259 Now I need to count A/T/G/C numbers at each character location in column... (2 Replies)
Discussion started by: thienxho
2 Replies

7. Shell Programming and Scripting

sed to replace specific positions on line with file contents

Hi, I am trying to use an awk command to replace specific character positions on a line beginning with 80 with contents of another file. The line beginning with 80 in file1 is as follows: I want to replace the 000000000178800 (positions 34 - 49) on this file with the contents of... (2 Replies)
Discussion started by: nwalsh88
2 Replies

8. UNIX for Dummies Questions & Answers

Replace alphabets from certain positions

Hi all, I have column 2 full of values like HIVE4A-56 and HIVE4-56. I want to convert all values like HIVE4A-56 to HIVE4-56. So basically I want to delete all single alphabets before the '-' which is always preceded by a number. Values already in the desired format should remain unchanged... (4 Replies)
Discussion started by: ames1983
4 Replies

9. Shell Programming and Scripting

Filter lines based on values at specific positions

hi. I have a Fixed Length text file as input where the character positions 4-5(two character positions starting from 4th position) indicates the LOB indicator. The file structure is something like below: 10126Apple DrinkOmaha 10231Milkshake New Jersey 103 Billabong Illinois ... (6 Replies)
Discussion started by: kumarjt
6 Replies

10. Shell Programming and Scripting

Search and replace specific positions of specific lines

Hi, I have a file with hundreds of lines. I want to search for particular lines starting with 4000, search and replace the 137-139 position characters; which will be '000', with '036'. Can all of this be done without opening a temp file and then moving that temp file to the original file name. ... (7 Replies)
Discussion started by: dsid
7 Replies
authority::shared(3pm)					User Contributed Perl Documentation				    authority::shared(3pm)

NAME
authority::shared - a multi-AUTHORITY method for your classes SYNOPSIS
package MyApp; BEGIN { $MyApp::AUTHORITY = 'cpan:JOE'; } use authority::shared qw(cpan:ALICE cpan:BOB); package main; use feature qw(say); say scalar MyApp->AUTHORITY; # says "cpan:JOE" MyApp->AUTHORITY('cpan:JOE'); # lives MyApp->AUTHORITY('cpan:ALICE'); # lives MyApp->AUTHORITY('cpan:BOB'); # lives MyApp->AUTHORITY('cpan:CAROL'); # croaks DESCRIPTION
This module allows you to indicate that your module is issued by multiple authorities. The package variable $AUTHORITY should still be used to indicate the primary authority for the package. This module does two simple things: 1. Creates an @AUTHORITIES array in the caller package, populating it with the arguments passed to "authority::shared" on the "use" line. 2. Exports an AUTHORITY function to your package that reads the $AUTHORITY and @AUTHORITIES package variables. The main use case for shared authorities is for team projects. The team would designate a URI to represent the team as a whole. For example, "http://datetime.perl.org/", "http://moose.iinteractive.com/" or "http://www.perlrdf.org/". Releases can then be officially stamped with the authority of the team using: use authority::shared q<http://www.perlrdf.org/>; And users can check they have an module released by the official team using: RDF::TakeOverTheWorld->AUTHORITY(q<http://www.perlrdf.org/>); which will croak if package RDF::TakeOverTheWorld doesn't have the specified authority. BUGS
An obvious limitation is that this module relies on honesty. Don't release modules under authorities you have no authority to use. Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=authority-shared <http://rt.cpan.org/Dist/Display.html?Queue=authority-shared>. SEE ALSO
o Object::AUTHORITY - an AUTHORITY method for your class o authority::shared (this module) - a more sophisticated AUTHORITY method for your class o UNIVERSAL::AUTHORITY - an AUTHORITY method for every class (deprecated) o UNIVERSAL::AUTHORITY::Lexical - an AUTHORITY method for every class, within a lexical scope o authority - load modules only if they have a particular authority Background reading: <http://feather.perl6.nl/syn/S11.html>, <http://www.perlmonks.org/?node_id=694377>. AUTHOR
Toby Inkster <tobyink@cpan.org>. COPYRIGHT AND LICENCE
This software is copyright (c) 2011 by Toby Inkster. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. perl v5.14.2 2011-12-15 authority::shared(3pm)
All times are GMT -4. The time now is 07:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy