Sponsored Content
Top Forums Shell Programming and Scripting regexp to get first line of string Post 302116834 by anbu23 on Wednesday 9th of May 2007 02:17:59 AM
Old 05-09-2007
Code:
grep -n "$1" "$file" | read output

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

RegExp: From first occurrance to last (at line start)

So I have a log that contains something like this: What I want is to get the first occurrence of "^localhost0" (at line start) and then everything else up to the last occurrence of "^localhost0" (at line start) Ideally I don't even care about the 2 "localhost0" lines either. All I really... (6 Replies)
Discussion started by: jjinno
6 Replies

2. UNIX for Dummies Questions & Answers

print the line immediately after a regexp; but regexp is a sentence

Good Day, Im new to scripting especially awk and sed. I just would like to ask help from you guys about a sed command that prints the line immediately after a regexp, but not the line containing the regexp. sed -n '/regexp/{n;p;}' filename What if my regexp is 3 word or a sentence. Im... (3 Replies)
Discussion started by: ownins
3 Replies

3. Shell Programming and Scripting

use regexp to insert newline within a line

I have successfully used regexp and sed to insert a newline before or after a line containing a matched pattern /WORD/. However, I want to insert a newline immediately following /WORD/ and not after the -line- containing the pattern matched. I can match a pattern, but it is matched via a wild card... (2 Replies)
Discussion started by: kpeirce
2 Replies

4. Shell Programming and Scripting

...yet another string of awk/sed questions from a RegExp-Challenged luser %-\

Greetings all, ...here is yet another string of awk/sed questions from a RegExp-Challenged luser :eek: I'm looking to have sed/awk do some clean-up on routing tables and to that end, I would like to do the following: 1.) If a line contains the word "masks" or "subnets" prepend CR/LF to... (16 Replies)
Discussion started by: SteveB-in-LV
16 Replies

5. Shell Programming and Scripting

extract string until regexp from backside

Hi, I searched in the forums, but I didn't find a good solution. My problem is: I have a string like "TEST.ABC201005.MONTHLY.D101010203". I just want to have the string until the D100430, so that the string should look like: "TEST.ABC201005.MONTHLY.D" The last characters after the D can be... (8 Replies)
Discussion started by: elifchen
8 Replies

6. UNIX for Dummies Questions & Answers

regexp: match string that contains list of chars

Hi, I'm curious about how to do a very simple thing with regular expressions that I'm unable to figure out. If I want to find out if a string contains 'a' AND 'b' AND 'c' it can be very easily done with grep: echo $STRING|grep a|grep b|grep c but, how would you do that in a single... (9 Replies)
Discussion started by: jimcanoa
9 Replies

7. Shell Programming and Scripting

How to use regexp to find an ipaddress from a query string?

I need help with a regexp to find out the ip address which can possibly be present in a URL. The URLs can be in any of the following form <domain>?a=12345&d=somestring1 <domain>?c=10.10.10.100&d=somestring1 <domain>?a=12345&b=somestring1&c=10.1.2.4d=somestring2... (3 Replies)
Discussion started by: ampak
3 Replies

8. Shell Programming and Scripting

Regexp for string that might contain a given character

I'm probably just not thinking of the correct term to search for :-) But I want to match a pattern that might be 'ABC' or '1ABC' there might be three characters, or there might be four, but if there are four, the first has to be 1 (1 Reply)
Discussion started by: jnojr
1 Replies

9. Shell Programming and Scripting

Print 4th line back from regexp

I'm looking for a way to print the 4th line back from a regular expression. Kind of like the below but it has to be the 4th line before the regexp. Print the line immediately before regexp, but not the line containing the regexp. sed -n '/regexp/{g;1!p;};h' here is an example of logs(i... (11 Replies)
Discussion started by: senormarquez
11 Replies

10. Shell Programming and Scripting

find and Replace String in Perl - Regexp

Trying to find and replace one string with another string in a file #!/usr/bin/perl $csd_table_path = "/file.ntab"; $find_str = '--bundle_type=021'; $repl_str = '--bundle_type=021 --target=/dev/disk1s2'; if( system("/usr/bin/perl -p -i -e 's/$find_str/$repl_str/' $csd_table_path")... (2 Replies)
Discussion started by: cillmor
2 Replies
Locale::Codes::LangFam(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangFam(3pm)

NAME
Locale::Codes::LangFam - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangFam; $lext = code2langfam('apa'); # $lext gets 'Apache languages' $code = langfam2code('Apache languages'); # $code gets 'apa' @codes = all_langfam_codes(); @names = all_langfam_names(); DESCRIPTION
The "Locale::Codes::LangFam" module provides access to standard codes used for identifying language families, such as those as defined in ISO 639-5. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default ISO 639-5 language family codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language families. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langfam('apa','alpha'); $lext = code2langfam('apa',LOCALE_LANGFAM_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from ISO 639-5 such as 'apa' for Apache languages. This is the default code set. ROUTINES
code2langfam ( CODE [,CODESET] ) langfam2code ( NAME [,CODESET] ) langfam_code2code ( CODE ,CODESET ,CODESET2 ) all_langfam_codes ( [CODESET] ) all_langfam_names ( [CODESET] ) Locale::Codes::LangFam::rename_langfam ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangFam::add_langfam ( CODE ,NAME [,CODESET] ) Locale::Codes::LangFam::delete_langfam ( CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_alias ( NAME ,NEW_NAME ) Locale::Codes::LangFam::delete_langfam_alias ( NAME ) Locale::Codes::LangFam::rename_langfam_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::delete_langfam_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.loc.gov/standards/iso639-5/id.php ISO 639-5 . AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.18.2 2013-11-04 Locale::Codes::LangFam(3pm)
All times are GMT -4. The time now is 10:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy