Sponsored Content
Top Forums Shell Programming and Scripting awk variables in regex expression ? Post 302486115 by vilius on Friday 7th of January 2011 04:02:47 AM
Old 01-07-2011
awk variables in regex expression ?

Hello,

Could someone explain why this one returns nothing:
Code:
$ x=/jon/
$ echo jon | awk -v xa=$x '$1~xa {print}'
$

while the following works fine:
Code:
$ x=jon
$ echo jon | awk -v xa=$x '$1==xa {print}'
$ jon

and the following works fine:
Code:
$ echo jon | awk '$1~/jon/ {print}'
$ jon

using bash.

thanks
V

Last edited by vilius; 01-07-2011 at 05:34 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace if regex on specific column matches expression?

I am attempting to convert rewrite rules to Nginx, and since due to the mass amount of rewrites we must convert, I've been trying to write a script to help me on a specific part, easily. So far I have this: rewrite ^action/static/(+)/$ staticPage.php?pg=$1&%$query_string; What I want done... (5 Replies)
Discussion started by: EXT3FSCK
5 Replies

2. Shell Programming and Scripting

Regular expression (regex) required

I want to block all special characters except alphanumerics.. and "."(dot ) character currently am using // I want to even block only single dot or multiple dots.. ex: . or .............. should be blocked. please provide me the reg ex. ---------- Post updated at 05:11 AM... (10 Replies)
Discussion started by: shams11
10 Replies

3. Shell Programming and Scripting

Creating a regex expression

Good morning all!! In my code I and looking through file /etc/syslog.congf and printing every line that has /var/log in it. I need to turn the if 9$line) into a regex code instead. #!/usr/bin/perl @file= 'cat /etc/syslog.conf'; //when foreach $line (@file){ if ($line =~... (3 Replies)
Discussion started by: bigben1220
3 Replies

4. Shell Programming and Scripting

help with simple regex expression

I am trying to grep the following line in a file using a bash shell: (..) admin1::14959:::::: (..) It works with the following expression (as expected) # cat file | grep ^*:: admin1::14959:::::: but it does not work with (not expected) # cat /etc/shadow | grep ^+:: I assume the... (2 Replies)
Discussion started by: schms
2 Replies

5. Shell Programming and Scripting

passing a regex as variable to awk and using that as regular expression for search

Hi All, I have a sftp session log where I am transferring multi files by issuing "mput abc*.dat". The contents of the logfile is below - ################################################# Connecting to 10.75.112.194... Changing to: /home/dasd9x/testing1 sftp> mput abc*.dat Uploading... (7 Replies)
Discussion started by: k_bijitesh
7 Replies

6. Emergency UNIX and Linux Support

Regular expression (regex) clean up text

Hi, Server - MEDIAWIKI - MYSQL - CENTOS 5 - PHP5 I have a database import of close to a million pages into my wiki, mediawiki site, the format that were left with is not pretty, and I need to find a way to clean this up and present it nicely... I think regex is the best option as I can... (1 Reply)
Discussion started by: lawstudent
1 Replies

7. Shell Programming and Scripting

Hi im new to bash scripting I want to know what does the regex expression do ??

# check host value regex='^(||1|2|25)(\.(||1|2|25)){3}$' if ')" != "" ]; then if ]; then echo host $host not found exit 4 fi elif ]; then echo $host is an invalid host address exit 5 fi (1 Reply)
Discussion started by: kevin298
1 Replies

8. Shell Programming and Scripting

awk regex expression works in AIX but not in Linux

I have following expression: echo "Sun 12 Jul BST 2014\nSun 12 Jul 2014\nSun 12 Jul IS 2014" | awk '/(Sun)+( 12)+( Jul )+({3} )?(2014)/{print;}' I ran above code in AIX box and output is as follows Sun 12 Jul BST 2014 Sun 12 Jul 2014 I ran above code in Linux box and output is as... (8 Replies)
Discussion started by: kamlesh_pradhan
8 Replies

9. UNIX for Beginners Questions & Answers

Regex Expression Replace

I have a XML file where there is a tag with like <wd:address_line_1>1234 Street</wd:address_line_1> I want to replace the values "1234 Street" with "Test Data". Different people have different address lines and i want to replace with a fixed value to mask the file. I was trying to use sed... (7 Replies)
Discussion started by: dr46014
7 Replies

10. UNIX for Beginners Questions & Answers

Sed: -e expression #1, char 20: unterminated address regex

I am trying to add word in last of particular line. the same command syntex is running on prompt. but in bash script give error."sed: -e expression #1, char 20: unterminated address regex" Please help. for i in `cat servername`; do ssh -q -t root@$i sed -i '/simple_allow_groups =/s/$/,... (4 Replies)
Discussion started by: yash_message
4 Replies
SOCKS_CLIENTS(1)					      General Commands Manual						  SOCKS_CLIENTS(1)

NAME
rfinger - SOCKS client version of finger rftp - SOCKS client version of ftp rtelnet - SOCKS client version of telnet rwhois - SOCKS client version of whois SYNOPSIS
See the man pages on finger(1), ftp(1), telnet(1), whois(1). DESCRIPTION
These programs provide the well-known functionalities to hosts within a firewall. Normally, when a firewall is constructed, IP-accessibil- ity across the firewall is cut off to reduce security risk to hosts within the firewall. As a result, inside hosts can no longer use many of the well-known tools directly to access the resources outside the firewall. These programs restore the convenience of the well-known tools while maintaining the security requirement. Though the programs differ very much from their counterparts in the use of the communication scheme, they should behave almost indistinguishable to the users. Note though that rftp does echo the password as you type it in if you are using anonymous as log-in name. Unlike those of the previous versions, these are "versatile" clients, meaning that they can be used for connections to inside hosts directly and to outside hosts via SOCKS proxy servers. So they can be used as replacements of their traditional counterparts. When any of these programs starts, if the environment variable SOCKS_BANNER is defined, the program prints to stderr its version number and the name or IP address of its default SOCKS proxy server. It then consults the configuration file to determine whether a request should be allowed or denied based on the requesting user, the destination host, and the requested service. For allowable requests, the configuration file also dictates whether direct or proxy connection should be used to the given destination, and optionally the actual SOCKS servers to use for the proxy connection. The program lookps first for the frozen configuration file /etc/socks.fc first. If that's not found, it then looks for the file /etc/socks.conf. If both files are absent, these programs will only try direct connections to the destination hosts, making them behaving like their regular counterparts. You can use environment variable SOCKS_NS to set the nameserver for domainname resolutions. Be sure you use the IP address of the name- server you want to use, not its domainname. If SOCKS_NS doesn't exist, the IP address defined by the symbol SOCKS_DEFAULT_NS at compile time is used if the programs were compiled with that symbol defined. Otherwise the nameservers specified in /etc/resolv.conf are used. All the client programs uses syslog with facility daemon and level notice to log their activities. These log lines usually appear in file /var/adm/messages though that can be changed by modifying /etc/syslog.conf. (See syslogd(8) and syslog.conf(5).) Typical lines look like Apr 11 10:02:23 eon rfinger[631]: connect() from don(don) to abc.com (finger) using sockd at socksserv May 10 08:39:07 eon rftp[603]: connect() directly from blue(blue) to xyz.edu (ftp) May 10 08:39:09 eon rftp[603]: bind() directly from blue(blue) for xyz.edu (ftp) May 18 13:31:19 eon rtelnet[830]: connect() from root(jon) to xyz.edu (telnet) using sockd at sockd2 May 18 14:51:19 eon rtelnet[921]: refused -- connect() from jon(jon) to xyz.edu (telnet) Of the two user-ids appearing in each log line, the first is the effective user-id when the program is invoked, the second (that within the parentheses) is the one used at login. Access control applies to the effective user-ids. SEE ALSO
finger(1), ftp(1), sockd(8), sockd.conf(5), socks.conf(5), telnet(1), whois(1) ENVIRONMENT
SOCKS_SERVER, if defined, specifies the name or IP address of the SOCKS proxy server host to use, overriding the default server compiled into the programs. SOCKS_NS, if defined, specify the IP address of the domain nameserver that should be used for name resolution, overriding both the defini- tion of symbol SOCKS_DEFAULT_NS and the file /etc/resolv.conf. ORIG_FINGER, if defined, specified the (altered) full pathname of the original finger program, which should have been renamed before installing the rfinger as the regular finger. The rfinger program invokes the original finger program to lookup information on local users. Normally this name should be compiled directly into rfinger, avoiding the need for this environment variable. Use ORIG_FINGER only if you want to override what is compiled into rfinger. AUTHOR
David Koblas, koblas@netcom.com Ying-Da Lee, ylee@syl.dl.nec.com May 6, 1996 SOCKS_CLIENTS(1)
All times are GMT -4. The time now is 12:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy