Sponsored Content
Top Forums Shell Programming and Scripting sed - extracting the first word only if match Post 302859353 by jethrow on Thursday 3rd of October 2013 12:24:17 AM
Old 10-03-2013
Here's another example:
Code:
echo "WORD1 code1=value1-idkey1 code2=value1" | perl -pe "s;.*?=(\S+).*;\1;"

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extracting from second word

Hi all, I need to extract the Particular string from the whole word,the input file is : 123,345,aaaa,555,....,.... I need all the record from 345 so i need to eliminate the first record. Output: 345,aaa,5555,....,.....,..... Thanks in advance. (3 Replies)
Discussion started by: ithirak17
3 Replies

2. Programming

sed no match word end with hyphen

Hi, This is my first post.It has two parts first part: I want to match a line that starts with whitespace tab or similar followed by must start with specific word and not match same word start with hyphen like this: grep height file1: height: 150px; line-height: 1.5em; height:... (4 Replies)
Discussion started by: medium_linux
4 Replies

3. UNIX for Dummies Questions & Answers

extracting sentences that only contain a word

Hi guys Need your help how do I extract sentences with only a word i.e. today is hot hot very humid humid2 Sample output hot very (0 Replies)
Discussion started by: jamestan
0 Replies

4. Shell Programming and Scripting

extracting sentences that only contain a word

Hi guys Need your help how do I extract sentences with only a word i.e. today is hot hot very humid humid2 Sample output hot (6 Replies)
Discussion started by: jamestan
6 Replies

5. Shell Programming and Scripting

Extracting a word from a variable

Hi Guys, Need you quick assistance on the below, trying to extract a word from a variable i.e. acmi101acmi102acmi103acmi104 When i use the following code awk '{gsub(/cmi102/,"")};1' it leaves a space in the variable, need to get rid of the space that it leaves. Any ideas. the above... (3 Replies)
Discussion started by: eo29
3 Replies

6. Shell Programming and Scripting

Problems extracting word using SED

I have a file containing strings such as: UPDATE PS_CA_BI_FF2_TA3 SET DELETE_ME = 'Y' WHERE PROCESS_INSTANCE BI.LAST_UPDATE_DTTM FROM PS_CA_BP_LINES LINE, PS_INTFC_BI BI WHERE EXISTS ( SELECT 'X' FROM PS_CA_BILL_PLAN BP WHERE BP.CONTRACT_NUM %Select(COUNTER4) SELECT COUNT(*) FROM PS_INTFC_BI... (2 Replies)
Discussion started by: simpletech369
2 Replies

7. UNIX for Dummies Questions & Answers

Extracting part of a word

I have the code message={TP=2012:09:23:00:00:00:GMT,SD=2012:09:23:00:00:00:GMT,SP=2,FT=CCGT,FG=3605} I want to extract the FG=3605 parts of this. Please help. I am trying to do this using awk or unix. (5 Replies)
Discussion started by: JenniferTopham
5 Replies

8. Shell Programming and Scripting

Replacing first word while extracting

Hello All, I am extracting a part of file. the file looks as follows USING CHARACTER SET UTF8 DEFINE JOB ( DEFINE SCHEMA Flat_File_Schema ( cntnt_id VARCHAR(10) ); DEFINE OPERATOR o_mload TYPE update SCHEMA * ATTRIBUTES ( VARCHAR TdpId = @TdpId (5 Replies)
Discussion started by: nnani
5 Replies

9. Shell Programming and Scripting

Replacing the first word if the word three match

Dear ALL, I have sample file : IDcentos-forum,bash,linuxCentOS,GNome IEfedora-milis,cli,linuxRedhat,KDE IRfreebsd-milis,aix,unixbsd,pyton required output: centos,bash,linuxCentOS,GNome fedora,cli,linuxRedhat,KDE freebsd,aix,unixbsd,pyton Can you help me pls.. (1 Reply)
Discussion started by: gnulyn
1 Replies

10. UNIX for Beginners Questions & Answers

sed script to delete the last word after a last pattern match

Hi Guys , I am having a file as stated below File 1 sa0 -- i_core/i_core_apb/i_afe0_controller/U261/A sa0 -- i_core/i_core_apb/i_afe0_controller/U265/Z sa1 -- i_core/i_core_apb/i_afe0_controller/U265/A sa1 -- i_core/i_core_apb/i_afe0_controller/U268/Z sa1 -- ... (7 Replies)
Discussion started by: kshitij
7 Replies
Affixes(3pm)						User Contributed Perl Documentation					      Affixes(3pm)

NAME
Text::Affixes - Prefixes and suffixes analisys of text SYNOPSIS
use Text::Affixes; my $text = "Hello, world. Hello, big world."; my $prefixes = get_prefixes($text); # $prefixes now holds # { # 3 => { # 'Hel' => 2, # 'wor' => 2, # } # } # or $prefixes = get_prefixes({min => 1, max => 2},$text); # $prefixes now holds # { # 1 => { # 'H' => 2, # 'w' => 2, # 'b' => 1, # }, # 2 => { # 'He' => 2, # 'wo' => 2, # 'bi' => 1, # } # } # the use for get_suffixes is similar DESCRIPTION
Provides methods for prefixe and suffix analisys of text. METHODS
get_prefixes Extracts prefixes from text. You can specify the minimum and maximum number of characters of prefixes you want. Returns a reference to a hash, where the specified limits are mapped in hashes; each of those hashes maps every prefix in the text into the number of times it was found. By default, both minimum and maximum limits are 3. If the minimum limit is greater than the lower one, an empty hash is returned. A prefix is considered to be a sequence of word characters (w) in the beginning of a word (that is, after a word boundary) that does not reach the end of the word ("regular expressionly", a prefix is the $1 of /(w+)w/). # extracting prefixes of size 3 $prefixes = get_prefixes( $text ); # extracting prefixes of sizes 2 and 3 $prefixes = get_prefixes( {min => 2}, $text ); # extracting prefixes of sizes 3 and 4 $prefixes = get_prefixes( {max => 4}, $text ); # extracting prefixes of sizes 2, 3 and 4 $prefixes = get_prefixes( {min => 2, max=> 4}, $text); get_suffixes The get_suffixes function is similar to the get_prefixes one. You should read the documentation for that one and than come back to this point. A suffix is considered to be a sequence of word characters (w) in the end of a word (that is, before a word boundary) that does not start at the beginning of the word ("regular expressionly" speaking, a prefix is the $1 of /w(w+)/). # extracting suffixes of size 3 $suffixes = get_suffixes( $text ); # extracting suffixes of sizes 2 and 3 $suffixes = get_suffixes( {min => 2}, $text ); # extracting suffixes of sizes 3 and 4 $suffixes = get_suffixes( {max => 4}, $text ); # extracting suffixes of sizes 2, 3 and 4 $suffixes = get_suffixes( {min => 2, max=> 4}, $text); OPTIONS
Apart from deciding on a minimum and maximum size for prefixes or suffixes, you can also decide on some configuration options. exclude_numbers Set to 0 if you consider numbers as part of words. Default value is 1. # this get_suffixes( {min => 1, max => 1, exclude_numbers => 0}, "Hello, but w8" ); # returns this: { 1 => { 'o' => 1, 't' => 1, '8' => 1 } } lowercase Set to 1 to extract all prefixes in lowercase mode. Default value is 0. ATTENTION: This does not mean that prefixes with uppercased characters won't be extracted. It means they will be extracted after being lowercased. # this... get_prefixes( {min => 2, max => 2, lowercase => 1}, "Hello, hello"); # returns this: { 2 => { 'he' => 2 } } TO DO
o Make it more efficient (use C for that) AUTHOR
Jose Castro, "<cog@cpan.org>" COPYRIGHT &; LICENSE Copyright 2004 Jose Castro, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.0 2005-11-19 Affixes(3pm)
All times are GMT -4. The time now is 11:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy