Sponsored Content
Top Forums Shell Programming and Scripting Search comppare replace (substr/lppad) Post 302973143 by RudiC on Sunday 15th of May 2016 02:47:21 AM
Old 05-15-2016
Is it possible you searched for 8 chars to be replaced by a 4 char zero padded string? Try
Code:
awk ' 
        {split (POS, P, "-")
         P[2]++
         LEN = P[2] - P[1]
         printf "%s%0*d%s\n", substr($0, 1, P[1]-1), LEN, substr($0, P[1], LEN), substr ($0, P[2])
        }
' POS="45-55" file
XXXXXXX XXXXX                 MM11111    ZM    0         000000000000000000000OREGON XXXXXXX HXN  001111  01010  -->Original
XXXXXXX XXXXX                 MM11111    ZM 00000000000  000000000000000000000OREGON XXXXXXX HXN  001111  01010  --> After

This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl: Search for string on line then search and replace text

Hi All, I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text. An example of 4 lines in my file is: 1. MatchText_randomNumberOfText moreData ReplaceMe moreData 2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies

2. Shell Programming and Scripting

Search and replace

Hi All, Suppose I have a file "a.doc" It's contents are : mos44.0 ) ..... ...... ..... export TKTS_RELEASE=tkts44.0b7 ...... ....... Now , I need to first search for the pattern "mos44.0 )" and then TKTS_RELEASE will... (8 Replies)
Discussion started by: sanyerra
8 Replies

3. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

4. Shell Programming and Scripting

perl search and replace - search in first line and replance in 2nd line

Dear All, i want to search particular string and want to replance next line value. following is the test file. search string is tmp,??? ,10:1 "???" may contain any 3 character it should remain the same and next line replace with ,10:50 tmp,123 --- if match tmp,??? then... (3 Replies)
Discussion started by: arvindng
3 Replies

5. Shell Programming and Scripting

AWK Substr - find and replace question...

Hello Experts, I have a input file that I need to replace a value only if the file contains the number 6 in column 1. I would like to use AWK in a shell script (ksh on a AIX platform). I need all rows written out, but only change 2 fields when the first column contains a numer 6. Input... (2 Replies)
Discussion started by: scottb
2 Replies

6. UNIX for Dummies Questions & Answers

Help with search and replace or search only of / in vi

Hi all, I am editing a config file in vi that has a / on it. At the moment, search and replace looks alright as am able to use a # as a temporary separator, i.e. :,$s#/u01/app#/u02/app#g For doing a search, I have to escape the / do. So if I want to search for /u01/app, I am having to do... (2 Replies)
Discussion started by: newbie_01
2 Replies

7. Shell Programming and Scripting

search and replace.

Hi, I have a file which contains data in this form. /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */;... (2 Replies)
Discussion started by: arijitsaha
2 Replies

8. Shell Programming and Scripting

Search for a substr with nawk

Hi, I have files, with fixed length fields/let's say every field 5 positions/, like this: xxxx 140 xxxxx xxxx 140 xxxxx xxxx 1400 xxxxx xxxx 150 xxxxx I need to get only the records, which have 140 in the second column. I use that command: nawk '{if (substr($0,6,3)=="140") print $0}'... (3 Replies)
Discussion started by: apenkov
3 Replies

9. Shell Programming and Scripting

Nested search in a file and replace the inner search

Hi Team, I am new to unix, please help me in this. I have a file named properties. The content of the file is : ##Mobile props east.url=https://qa.east.corp.com/prop/end west.url=https://qa.west.corp.com/prop/end south.url=https://qa.south.corp.com/prop/end... (2 Replies)
Discussion started by: tolearn
2 Replies

10. Shell Programming and Scripting

awk to comppare two files using rwo fields

I use the two awk scripts for comparing file1 and file2. First awk compare $3 column: awk -v OFS="\t" 'NR==FNR{a=$4;next}{$2=$2 "\t"(a?a:"-")}1' file1 file2Second awk compare $2 column: awk -v OFS="\t" 'NR==FNR{a=$4;next}{$2=$2 "\t"(a?a:"-")}1' file1 file2 The only difference ... (12 Replies)
Discussion started by: cmccabe
12 Replies
DateTime::Locale::mr(3) 				User Contributed Perl Documentation				   DateTime::Locale::mr(3)

NAME
DateTime::Locale::mr SYNOPSIS
use DateTime; my $dt = DateTime->now( locale => 'mr' ); print $dt->month_name(); DESCRIPTION
This is the DateTime locale package for Marathi. DATA
This locale inherits from the DateTime::Locale::root locale. It contains the following data. Days Wide (format) XXXXXX XXXXXXX XXXXXX XXXXXXX XXXXXXXX XXXXXX XXXXXX Abbreviated (format) XXX XXXX XXX XXXX XXXXX XXX XXX Narrow (format) XX XX XX XX XX X X Wide (stand-alone) XXXXXX XXXXXXX XXXXXX XXXXXXX XXXXXXXX XXXXXX XXXXXX Abbreviated (stand-alone) XXX XXXX XXX XXXX XXXXX XXX XXX Narrow (stand-alone) XX XX XX XX XX X X Months Wide (format) XXXXXXXX XXXXXXXXXX XXXXX XXXXXX XX XXX XXXX XXXXX XXXXXXXX XXXXXXX XXXXXXXXX XXXXXXX Abbreviated (format) XXXXXXXX XXXXXXXXXX XXXXX XXXXXX XX XXX XXXX XXXXX XXXXXXXX XXXXXXX XXXXXXXXX XXXXXXX Narrow (format) XX XX XX X XX XX XX X X X XX XX Wide (stand-alone) XXXXXXXX XXXXXXXXXX XXXXX XXXXXX XX XXX XXXX XXXXX XXXXXXXX XXXXXXX XXXXXXXXX XXXXXXX Abbreviated (stand-alone) 1 2 3 4 5 6 7 8 9 10 11 12 Narrow (stand-alone) XX XX XX X XX XX XX X X X XX XX Quarters Wide (format) XXXXX XXXXXX XXXXXXX XXXXXX XXXXX XXXXXX XXXXXX XXXXXX Abbreviated (format) Q1 Q2 Q3 Q4 Narrow (format) 1 2 3 4 Wide (stand-alone) XXXXX XXXXXX XXXXXXX XXXXXX XXXXX XXXXXX XXXXXX XXXXXX Abbreviated (stand-alone) Q1 Q2 Q3 Q4 Narrow (stand-alone) 1 2 3 4 Eras Wide XXXXXXXXXXX XXXXXX Abbreviated X.X.XX. X.X. Narrow X.X.XX. X.X. Date Formats Full 2008-02-05T18:30:30 = XXXXXXX 5 XXXXXXXXXX 2008 1995-12-22T09:05:02 = XXXXXXXX 22 XXXXXXX 1995 -0010-09-15T04:44:23 = XXXXXX 15 XXXXXXXX -10 Long 2008-02-05T18:30:30 = 5 XXXXXXXXXX 2008 1995-12-22T09:05:02 = 22 XXXXXXX 1995 -0010-09-15T04:44:23 = 15 XXXXXXXX -10 Medium 2008-02-05T18:30:30 = 5 XXXXXXXXXX 2008 1995-12-22T09:05:02 = 22 XXXXXXX 1995 -0010-09-15T04:44:23 = 15 XXXXXXXX -10 Short 2008-02-05T18:30:30 = 5-2-08 1995-12-22T09:05:02 = 22-12-95 -0010-09-15T04:44:23 = 15-9--10 Default 2008-02-05T18:30:30 = 5 XXXXXXXXXX 2008 1995-12-22T09:05:02 = 22 XXXXXXX 1995 -0010-09-15T04:44:23 = 15 XXXXXXXX -10 Time Formats Full 2008-02-05T18:30:30 = 6-30-30 pm UTC 1995-12-22T09:05:02 = 9-05-02 am UTC -0010-09-15T04:44:23 = 4-44-23 am UTC Long 2008-02-05T18:30:30 = 6-30-30 pm UTC 1995-12-22T09:05:02 = 9-05-02 am UTC -0010-09-15T04:44:23 = 4-44-23 am UTC Medium 2008-02-05T18:30:30 = 6-30-30 pm 1995-12-22T09:05:02 = 9-05-02 am -0010-09-15T04:44:23 = 4-44-23 am Short 2008-02-05T18:30:30 = 6-30 pm 1995-12-22T09:05:02 = 9-05 am -0010-09-15T04:44:23 = 4-44 am Default 2008-02-05T18:30:30 = 6-30-30 pm 1995-12-22T09:05:02 = 9-05-02 am -0010-09-15T04:44:23 = 4-44-23 am Datetime Formats Full 2008-02-05T18:30:30 = XXXXXXX 5 XXXXXXXXXX 2008 6-30-30 pm UTC 1995-12-22T09:05:02 = XXXXXXXX 22 XXXXXXX 1995 9-05-02 am UTC -0010-09-15T04:44:23 = XXXXXX 15 XXXXXXXX -10 4-44-23 am UTC Long 2008-02-05T18:30:30 = 5 XXXXXXXXXX 2008 6-30-30 pm UTC 1995-12-22T09:05:02 = 22 XXXXXXX 1995 9-05-02 am UTC -0010-09-15T04:44:23 = 15 XXXXXXXX -10 4-44-23 am UTC Medium 2008-02-05T18:30:30 = 5 XXXXXXXXXX 2008 6-30-30 pm 1995-12-22T09:05:02 = 22 XXXXXXX 1995 9-05-02 am -0010-09-15T04:44:23 = 15 XXXXXXXX -10 4-44-23 am Short 2008-02-05T18:30:30 = 5-2-08 6-30 pm 1995-12-22T09:05:02 = 22-12-95 9-05 am -0010-09-15T04:44:23 = 15-9--10 4-44 am Default 2008-02-05T18:30:30 = 5 XXXXXXXXXX 2008 6-30-30 pm 1995-12-22T09:05:02 = 22 XXXXXXX 1995 9-05-02 am -0010-09-15T04:44:23 = 15 XXXXXXXX -10 4-44-23 am Available Formats d (d) 2008-02-05T18:30:30 = 5 1995-12-22T09:05:02 = 22 -0010-09-15T04:44:23 = 15 EEEd (d EEE) 2008-02-05T18:30:30 = 5 XXXX 1995-12-22T09:05:02 = 22 XXXXX -0010-09-15T04:44:23 = 15 XXX Hm (H-mm) 2008-02-05T18:30:30 = 18-30 1995-12-22T09:05:02 = 9-05 -0010-09-15T04:44:23 = 4-44 hm (h:mm a) 2008-02-05T18:30:30 = 6:30 pm 1995-12-22T09:05:02 = 9:05 am -0010-09-15T04:44:23 = 4:44 am Hms (H-mm-ss) 2008-02-05T18:30:30 = 18-30-30 1995-12-22T09:05:02 = 9-05-02 -0010-09-15T04:44:23 = 4-44-23 hms (h:mm:ss a) 2008-02-05T18:30:30 = 6:30:30 pm 1995-12-22T09:05:02 = 9:05:02 am -0010-09-15T04:44:23 = 4:44:23 am M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 Md (M-d) 2008-02-05T18:30:30 = 2-5 1995-12-22T09:05:02 = 12-22 -0010-09-15T04:44:23 = 9-15 MEd (E, M-d) 2008-02-05T18:30:30 = XXXX, 2-5 1995-12-22T09:05:02 = XXXXX, 12-22 -0010-09-15T04:44:23 = XXX, 9-15 MMdd (dd-MM) 2008-02-05T18:30:30 = 05-02 1995-12-22T09:05:02 = 22-12 -0010-09-15T04:44:23 = 15-09 MMM (LLL) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 MMMd (MMM d) 2008-02-05T18:30:30 = XXXXXXXXXX 5 1995-12-22T09:05:02 = XXXXXXX 22 -0010-09-15T04:44:23 = XXXXXXXX 15 MMMEd (E MMM d) 2008-02-05T18:30:30 = XXXX XXXXXXXXXX 5 1995-12-22T09:05:02 = XXXXX XXXXXXX 22 -0010-09-15T04:44:23 = XXX XXXXXXXX 15 MMMMd (d MMMM) 2008-02-05T18:30:30 = 5 XXXXXXXXXX 1995-12-22T09:05:02 = 22 XXXXXXX -0010-09-15T04:44:23 = 15 XXXXXXXX MMMMEd (E MMMM d) 2008-02-05T18:30:30 = XXXX XXXXXXXXXX 5 1995-12-22T09:05:02 = XXXXX XXXXXXX 22 -0010-09-15T04:44:23 = XXX XXXXXXXX 15 ms (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 y (y) 2008-02-05T18:30:30 = 2008 1995-12-22T09:05:02 = 1995 -0010-09-15T04:44:23 = -10 yM (y-M) 2008-02-05T18:30:30 = 2008-2 1995-12-22T09:05:02 = 1995-12 -0010-09-15T04:44:23 = -10-9 yMEd (EEE, y-M-d) 2008-02-05T18:30:30 = XXXX, 2008-2-5 1995-12-22T09:05:02 = XXXXX, 1995-12-22 -0010-09-15T04:44:23 = XXX, -10-9-15 yMMM (y MMM) 2008-02-05T18:30:30 = 2008 XXXXXXXXXX 1995-12-22T09:05:02 = 1995 XXXXXXX -0010-09-15T04:44:23 = -10 XXXXXXXX yMMMEd (EEE, y MMM d) 2008-02-05T18:30:30 = XXXX, 2008 XXXXXXXXXX 5 1995-12-22T09:05:02 = XXXXX, 1995 XXXXXXX 22 -0010-09-15T04:44:23 = XXX, -10 XXXXXXXX 15 yMMMM (y MMMM) 2008-02-05T18:30:30 = 2008 XXXXXXXXXX 1995-12-22T09:05:02 = 1995 XXXXXXX -0010-09-15T04:44:23 = -10 XXXXXXXX yQ (y Q) 2008-02-05T18:30:30 = 2008 1 1995-12-22T09:05:02 = 1995 4 -0010-09-15T04:44:23 = -10 3 yQQQ (y QQQ) 2008-02-05T18:30:30 = 2008 Q1 1995-12-22T09:05:02 = 1995 Q4 -0010-09-15T04:44:23 = -10 Q3 yyQ (Q yy) 2008-02-05T18:30:30 = 1 08 1995-12-22T09:05:02 = 4 95 -0010-09-15T04:44:23 = 3 -10 yyyyMM (MM-yyyy) 2008-02-05T18:30:30 = 02-2008 1995-12-22T09:05:02 = 12-1995 -0010-09-15T04:44:23 = 09--010 yyyyMMMM (MMMM y) 2008-02-05T18:30:30 = XXXXXXXXXX 2008 1995-12-22T09:05:02 = XXXXXXX 1995 -0010-09-15T04:44:23 = XXXXXXXX -10 Miscellaneous Prefers 24 hour time? No Local first day of the week XXXXXX SUPPORT
See DateTime::Locale. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT
Copyright (c) 2008 David Rolsky. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This module was generated from data provided by the CLDR project, see the LICENSE.cldr in this distribution for details on the CLDR data's license. perl v5.18.2 2017-10-06 DateTime::Locale::mr(3)
All times are GMT -4. The time now is 07:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy