Sponsored Content
Top Forums Shell Programming and Scripting Fetch the rows with match string on a fixed lenth text file - NO delimiters Post 302320286 by nareshk on Wednesday 27th of May 2009 02:05:34 PM
Old 05-27-2009
Quote:
Originally Posted by Rhije
grep is going to be working on a line by line basis, so grep ^09 is doing just what you asked it to do by finding any line that begins with 09

You probably want to use awk, it would be the easiest thing to do. If the data is in the same format that you provided, you could do something like the following:

Code:
awk '$4 == "0000001234"' file

By default (if you do not tell awk to print anything specific), it will print the entire record/row. So the above will only print a row if the fourth field is what is shown.

You could also use word boundaries in grep:

Code:
-bash-3.2$ cat test.txt
09 0 XXX 0000001234 Z 1
09 0 XXX 0000001234 Z 1
09 0 XXX 50000001234 Z 1
09 0 XXX 40000001234 Z 1
09 0 XXX 30000001234 Z 1
09 0 XXX 10000001234 Z 1

-bash-3.2$ grep "\<0000001234\>" test.txt
09 0 XXX 0000001234 Z 1
09 0 XXX 0000001234 Z 1

Hope that helps.

Thanks for your Help

what if the input file is like this

09 0 01000000001234 Z 1
09 0 01000000001234 Z 1
09 0 010050000001234 Z 1
09 0 010040000001234 Z 1
09 0 010030000001234 Z 1
09 0 010010000001234 Z 1

and now i want to fetch the rows with match string "0000001234" i.e search the string from 10th column to 19 th column and fetch the rows
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inserting new line after match of a fixed string

Hi, I have a file which contains many occurances of a string say "hellosunil". I want to insert a newline charcater after all the "hellosunil" strings in the file. trying to use sed, sed -e 's/hellosunil/\\nhellosunil/g' file1 sed help says u cannot substitute a regular expression... (6 Replies)
Discussion started by: sunil_neha
6 Replies

2. Programming

c program to extract text between two delimiters from some text file

needa c program to extract text between two delimiters from some text file. and then storing them in to diffrent variables ? text file like 0: abc.txt ========= aaaaaa|11111111|sssssssssss|333333|ddddddddd|34343454564|asass aaaaaa|11111111|sssssssssss|333333|ddddddddd|34343454564|asass... (7 Replies)
Discussion started by: kukretiabhi13
7 Replies

3. Shell Programming and Scripting

string deletion, variable contents, fixed delimiters

Hi, I need to mass delete the following string(s) from my files weight=100, However the '100' is variable e.g Current: ---------------- moretext=bar, weight=100, moreinfo=blah extrastuff=hi, weight=9999, extrainfo=foo Desired: ------------------ moretext=bar, moreinfo=blah... (2 Replies)
Discussion started by: rebelbuttmunch
2 Replies

4. Shell Programming and Scripting

Program to insert Delimiters at fixed locations in a file, Can you please Debug it for me??

Can someone please help?I have a file - fixed.txt----------------------------AABBBBCCCCCCDDDEEFFFFGGGGGGHHHIIJJJJKKKKKKLLL----------------------------To insert delimiters at fixed lengths of 2, 4, 6, 3, I created a file text1.txt as-------------------2463----------------------and trying to execute... (10 Replies)
Discussion started by: jd_mca
10 Replies

5. Shell Programming and Scripting

fetch last line no form file which is match with specific pattern by grep command

Hi i have a file which have a pattern like this Nov 10 session closed Nov 10 Nov 9 08:14:27 EST5EDT 2010 on tty . Nov 10 Oct 19 02:14:21 EST5EDT 2010 on pts/tk . Nov 10 afrtetryytr Nov 10 session closed Nov 10 Nov 10 03:21:04 EST5EDT 2010 Dec 8 Nov 10 05:03:02 EST5EDT 2010 ... (13 Replies)
Discussion started by: Himanshu_soni
13 Replies

6. Shell Programming and Scripting

Getting a string without fixed delimiters

I have a line of text for example aaaa bbbb cccc dddd eeee ffffff I would need to get the cccc however bbbb could be there or not. So whether bbbb is in the line or not I need cccc. I was looking at either awk or sed....and trying to start at c and end until the next space. Also... (11 Replies)
Discussion started by: bombcan1
11 Replies

7. Shell Programming and Scripting

Append spaces the rows to make it into a required fixed length file

I want to make a script to read row by row and find its length. If the length is less than my required length then i hav to append spaces to that paritucular row. Each row contains special characters, spaces, etc. For example my file contains , 12345 abcdef 234 abcde 89012 abcdefgh ... (10 Replies)
Discussion started by: Amrutha24
10 Replies

8. UNIX for Dummies Questions & Answers

Search String, Out matched text and input text for no match.

I need to search a string for some specific text which is no big deal using grep. My problem is when the search fails to find the text. I need to add text like "na" when my search does not match. I have tried this command but it does not work when I put the command in a loop in a bash script: ... (12 Replies)
Discussion started by: jojojmac5
12 Replies

9. Shell Programming and Scripting

UNIX command -Filter rows in fixed width file based on column values

Hi All, I am trying to select the rows in a fixed width file based on values in the columns. I want to select only the rows if column position 3-4 has the value AB I am using cut command to get the column values. Is it possible to check if cut -c3-4 = AB is true then select only that... (2 Replies)
Discussion started by: ashok.k
2 Replies

10. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies
DateTime::Locale::ti_ER(3)				User Contributed Perl Documentation				DateTime::Locale::ti_ER(3)

NAME
DateTime::Locale::ti_ER SYNOPSIS
use DateTime; my $dt = DateTime->now( locale => 'ti_ER' ); print $dt->month_name(); DESCRIPTION
This is the DateTime locale package for Tigrinya Eritrea. DATA
This locale inherits from the DateTime::Locale::ti locale. It contains the following data. Days Wide (format) XXX XXX XXX XXX XXX XXX XXXX Abbreviated (format) XXX XXX XXX XXX XXX XXX XXX Narrow (format) X X X X X X X Wide (stand-alone) XXX XXX XXX XXX XXX XXX XXXX Abbreviated (stand-alone) XXX XXX XXX XXX XXX XXX XXX Narrow (stand-alone) X X X X X X X Months Wide (format) XX XXXX XXXX XXXX XXXX XX XXX XXX XXXXX XXXX XXX XXXX Abbreviated (format) XX XXX XXX XXX XXX XX XXX XXX XXX XXX XXX XXX Narrow (format) XX XXX XXX XXX XXX XX XXX XXX XXX XXX XXX XXX Wide (stand-alone) XX XXXX XXXX XXXX XXXX XX XXX XXX XXXXX XXXX XXX XXXX Abbreviated (stand-alone) XX XXX XXX XXX XXX XX XXX XXX XXX XXX XXX XXX Narrow (stand-alone) X X X X X X X X X X X X Quarters Wide (format) Q1 Q2 Q3 Q4 Abbreviated (format) Q1 Q2 Q3 Q4 Narrow (format) 1 2 3 4 Wide (stand-alone) Q1 Q2 Q3 Q4 Abbreviated (stand-alone) Q1 Q2 Q3 Q4 Narrow (stand-alone) 1 2 3 4 Eras Wide BCE CE Abbreviated X/X X/X Narrow X/X X/X Date Formats Full 2008-02-05T18:30:30 = XXXX 05 XXXX XXXX 2008 X/X 1995-12-22T09:05:02 = XXXX 22 XXXX XXXX 1995 X/X -0010-09-15T04:44:23 = XXXX 15 XXXXX XXXX -10 X/X Long 2008-02-05T18:30:30 = 05 XXXX 2008 1995-12-22T09:05:02 = 22 XXXX 1995 -0010-09-15T04:44:23 = 15 XXXXX -10 Medium 2008-02-05T18:30:30 = 05-XXX-2008 1995-12-22T09:05:02 = 22-XXX-1995 -0010-09-15T04:44:23 = 15-XXX--10 Short 2008-02-05T18:30:30 = 05/02/08 1995-12-22T09:05:02 = 22/12/95 -0010-09-15T04:44:23 = 15/09/-10 Default 2008-02-05T18:30:30 = 05-XXX-2008 1995-12-22T09:05:02 = 22-XXX-1995 -0010-09-15T04:44:23 = 15-XXX--10 Time Formats Full 2008-02-05T18:30:30 = 6:30:30 XXX XXX UTC 1995-12-22T09:05:02 = 9:05:02 XXX XXX UTC -0010-09-15T04:44:23 = 4:44:23 XXX XXX UTC Long 2008-02-05T18:30:30 = 6:30:30 XXX XXX UTC 1995-12-22T09:05:02 = 9:05:02 XXX XXX UTC -0010-09-15T04:44:23 = 4:44:23 XXX XXX UTC Medium 2008-02-05T18:30:30 = 6:30:30 XXX XXX 1995-12-22T09:05:02 = 9:05:02 XXX XXX -0010-09-15T04:44:23 = 4:44:23 XXX XXX Short 2008-02-05T18:30:30 = 6:30 XXX XXX 1995-12-22T09:05:02 = 9:05 XXX XXX -0010-09-15T04:44:23 = 4:44 XXX XXX Default 2008-02-05T18:30:30 = 6:30:30 XXX XXX 1995-12-22T09:05:02 = 9:05:02 XXX XXX -0010-09-15T04:44:23 = 4:44:23 XXX XXX Datetime Formats Full 2008-02-05T18:30:30 = XXXX 05 XXXX XXXX 2008 X/X 6:30:30 XXX XXX UTC 1995-12-22T09:05:02 = XXXX 22 XXXX XXXX 1995 X/X 9:05:02 XXX XXX UTC -0010-09-15T04:44:23 = XXXX 15 XXXXX XXXX -10 X/X 4:44:23 XXX XXX UTC Long 2008-02-05T18:30:30 = 05 XXXX 2008 6:30:30 XXX XXX UTC 1995-12-22T09:05:02 = 22 XXXX 1995 9:05:02 XXX XXX UTC -0010-09-15T04:44:23 = 15 XXXXX -10 4:44:23 XXX XXX UTC Medium 2008-02-05T18:30:30 = 05-XXX-2008 6:30:30 XXX XXX 1995-12-22T09:05:02 = 22-XXX-1995 9:05:02 XXX XXX -0010-09-15T04:44:23 = 15-XXX--10 4:44:23 XXX XXX Short 2008-02-05T18:30:30 = 05/02/08 6:30 XXX XXX 1995-12-22T09:05:02 = 22/12/95 9:05 XXX XXX -0010-09-15T04:44:23 = 15/09/-10 4:44 XXX XXX Default 2008-02-05T18:30:30 = 05-XXX-2008 6:30:30 XXX XXX 1995-12-22T09:05:02 = 22-XXX-1995 9:05:02 XXX XXX -0010-09-15T04:44:23 = 15-XXX--10 4:44:23 XXX XXX 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 XXX 1995-12-22T09:05:02 = 22 XXX -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 XXX XXX 1995-12-22T09:05:02 = 9:05 XXX XXX -0010-09-15T04:44:23 = 4:44 XXX XXX 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 XXX XXX 1995-12-22T09:05:02 = 9:05:02 XXX XXX -0010-09-15T04:44:23 = 4:44:23 XXX XXX 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 = XXX, 2-5 1995-12-22T09:05:02 = XXX, 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 = XXX 1995-12-22T09:05:02 = XXX -0010-09-15T04:44:23 = XXX MMMd (MMM d) 2008-02-05T18:30:30 = XXX 5 1995-12-22T09:05:02 = XXX 22 -0010-09-15T04:44:23 = XXX 15 MMMEd (E MMM d) 2008-02-05T18:30:30 = XXX XXX 5 1995-12-22T09:05:02 = XXX XXX 22 -0010-09-15T04:44:23 = XXX XXX 15 MMMMd (MMMM d) 2008-02-05T18:30:30 = XXXX 5 1995-12-22T09:05:02 = XXXX 22 -0010-09-15T04:44:23 = XXXXX 15 MMMMdd (dd MMMM) 2008-02-05T18:30:30 = 05 XXXX 1995-12-22T09:05:02 = 22 XXXX -0010-09-15T04:44:23 = 15 XXXXX MMMMEd (E MMMM d) 2008-02-05T18:30:30 = XXX XXXX 5 1995-12-22T09:05:02 = XXX XXXX 22 -0010-09-15T04:44:23 = XXX XXXXX 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 = XXX, 2008-2-5 1995-12-22T09:05:02 = XXX, 1995-12-22 -0010-09-15T04:44:23 = XXX, -10-9-15 yMMM (y MMM) 2008-02-05T18:30:30 = 2008 XXX 1995-12-22T09:05:02 = 1995 XXX -0010-09-15T04:44:23 = -10 XXX yMMMEd (EEE, y MMM d) 2008-02-05T18:30:30 = XXX, 2008 XXX 5 1995-12-22T09:05:02 = XXX, 1995 XXX 22 -0010-09-15T04:44:23 = XXX, -10 XXX 15 yMMMM (y MMMM) 2008-02-05T18:30:30 = 2008 XXXX 1995-12-22T09:05:02 = 1995 XXXX -0010-09-15T04:44:23 = -10 XXXXX 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 yyMM (MM/yy) 2008-02-05T18:30:30 = 02/08 1995-12-22T09:05:02 = 12/95 -0010-09-15T04:44:23 = 09/-10 yyQ (Q yy) 2008-02-05T18:30:30 = 1 08 1995-12-22T09:05:02 = 4 95 -0010-09-15T04:44:23 = 3 -10 yyyyMMMM (MMMM y) 2008-02-05T18:30:30 = XXXX 2008 1995-12-22T09:05:02 = XXXX 1995 -0010-09-15T04:44:23 = XXXXX -10 Miscellaneous Prefers 24 hour time? No Local first day of the week XXX 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.16.2 2013-08-25 DateTime::Locale::ti_ER(3)
All times are GMT -4. The time now is 12:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy