Sponsored Content
Top Forums UNIX for Advanced & Expert Users can awk built-in "match" be exact?? Post 302276591 by farphe on Wednesday 14th of January 2009 07:33:16 AM
Old 01-14-2009
can awk built-in "match" be exact??

hello everybody,

as explained in the title, here is what I want:

str1="name1 name2 name3"
str2="name1"
str3="name"

I know that match(str1,str2) will return 1, but I want that match(str1,str3) returns 0 (when it also returns 1...)

Is there a way to get that exact matching process done in a awk script??

cheers,
Tanguy
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

3. Shell Programming and Scripting

awk statement to match all lines starting with "#"

Looking for awk statement that will match all lines starting with "# " if ( $1 == \^"#" ) Input file: # of the server. If you would like to set these, please take out the # pound (#) sign in front of one or all severities and set it equal to # severity desired. For example, FATAL=3 #... (2 Replies)
Discussion started by: Arsenalman
2 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

grep regex, match exact string which includes "/" anywhere on line.

I have a file that contains the 2 following lines (from /proc/mounts) /dev/sdc1 /mnt/backup2 xfs rw,relatime,attr2,noquota 0 0 /dev/sdb1 /mnt/backup xfs rw,relatime,attr2,noquota 0 0 I need to match the string in the second column exactly so that only one result is returned, e.g. > grep... (2 Replies)
Discussion started by: jelloir
2 Replies

6. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

7. Shell Programming and Scripting

"AND" string match using awk

Hiya, Using awk (as I already have an embedded calculation in the command) reading in a file of many thousands of lines I would like to extract only the lines with M values where field one is less than 62: Part example of my input file is: ... 89,63,AAY0772,M 38,66,AAY0772,f... (3 Replies)
Discussion started by: gafoleyo73
3 Replies

8. UNIX for Dummies Questions & Answers

Explanation on problem "match" function awk

Hello Unix experts, If I could get any explanations on why the code below doesn't work it would be great ! My input looks like that ("|" delimited): Saaaaabbbbbccccc|ok Sdddddfffffggggg|ok The goal is, if $2 is "ok", to remove everything before the pattern given in the match function... (5 Replies)
Discussion started by: lucasvs
5 Replies

9. UNIX for Advanced & Expert Users

AIX - io info get from "libperfstat" not match "iostat"

Hi, everyone. I need to write a program to get io info based on libperfstat. But the "write time" of a disk is just half of the value get from iostat. I'm confused and can't explain. Help please. How I calculate "write service time per sec": In iostat: write service... (0 Replies)
Discussion started by: jackliang
0 Replies

10. Shell Programming and Scripting

Search file containing ps results for a match "my.cnf" and then for a second match . "ok:" and

I need to find two matches in the output from ps. I am searching with ps -ef |grep mysql for: my.cnf /bin/sh /usr/bin/mysqld_safe --defaults-file=/data/mysql/master/agis_core/etc/my.cnf after this match I want to search back and match the hostname which is x number of lines back, above the... (2 Replies)
Discussion started by: bash_in_my_head
2 Replies
Unicode::Escape(3pm)					User Contributed Perl Documentation				      Unicode::Escape(3pm)

NAME
Unicode::Escape - Escape and unescape Unicode characters other than ASCII VERSION
This document describes Unicode::Escape version 0.0.1 SYNOPSIS
# Escape Unicode charactors like '\u3042\u3043\u3044'. # JSON thinks No more Garble!! # case 1 use Unicode::Escape; my $escaped1 = Unicode::Escape::escape($str1, 'euc-jp'); # $str1 contains charactor that is not ASCII. $str1 is encoded by euc-jp. my $escaped2 = Unicode::Escape::escape($str2); # default is utf8 # $str2 contains charactor that is not ASCII. my $unescaped1 = Unicode::Escape::unescape($str3, 'shiftjis'); # $str3 contains escaped Unicode character. return value is encoded by shiftjis. my $unescaped2 = Unicode::Escape::unescape($str4); # default is utf8 # $str4 contains escaped Unicode character. # case 2 use Unicode::Escape qw(escape unescape); my $escaped1 = escape($str1, 'euc-jp'); # $str1 contains charactor that is not ASCII. $str1 is encoded by euc-jp. my $escaped2 = escape($str2); # default is utf8 # $str2 contains charactor that is not ASCII. my $unescaped1 = unescape($str3, 'shiftjis'); # $str3 contains escaped Unicode character. return value is encoded by shiftjis. my $unescaped2 = unescape($str4); # default is utf8 # $str4 contains escaped Unicode character. # case 3 use Unicode::Escape; my $escaper = Unicode::Escape->new($str, 'shiftjis'); # $str contains charactor that is not ASCII. $str is encoded by shiftjis.(default is utf8) my $escaped = $escaper->escape; # case 4 use Unicode::Escape; my $escaper = Unicode::Escape->new($str); # $str contains escaped Unicode character. my $unescaped1 = $escaper->unescape('shiftjis'); my $unescaped2 = $escaper->unescape; # default is utf8. DESCRIPTION
Escape and unescape Unicode characters other than ASCII. When the server response is javascript code, it is convenient. METHODS
new( $string[, $encode ] ) string Target string for escape or unescape. encode For instance, 'utf8', 'shiftjis', and 'euc-jp', etc. (See Encode) escape( $string[, $encode ] ) string Target string. This argument is unnecessary when called as object method. encode For instance, 'utf8', 'shiftjis', and 'euc-jp', etc. (See Encode) This argument is unnecessary when called as object method. unescape( $string[, $encode ] ) string Target string. This argument is unnecessary when called as object method. encode For instance, 'utf8', 'shiftjis', and 'euc-jp', etc. (See Encode) SEE ALSO
Unicode::String, Encode INCOMPATIBILITIES
None reported. BUGS AND LIMITATIONS
No bugs have been reported. Please report any bugs or feature requests to "bug-unicode-escape@rt.cpan.org", or through the web interface at <http://rt.cpan.org>. AUTHOR
Hitoshi Amano "<seijro@gmail.com>" LICENCE AND COPYRIGHT
Copyright (c) 2006, Hitoshi Amano "<seijro@gmail.com>". All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. perl v5.12.3 2011-06-05 Unicode::Escape(3pm)
All times are GMT -4. The time now is 02:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy