Sponsored Content
Top Forums Shell Programming and Scripting passing a regex as variable to awk and using that as regular expression for search Post 302599140 by k_bijitesh on Thursday 16th of February 2012 10:20:06 AM
Old 02-16-2012
Thanks. But in that case I'll end up getting the lines -
##############################################
Code:
-rw-r--r--    0 600598020 600598020        0 Feb 16 14:32 a.dat
-rw-r--r--    0 600598020 600598020       21 Feb 16 14:35 abc140212095613.dat
-rw-r--r--    0 600598020 600598020       25 Feb 16 14:35 abc140212095639.dat
-rw-r--r--    0 600598020 600598020       43 Feb 16 14:35 abc140212095648.dat
-rw-r--r--    0 600598020 600598020       35 Feb 16 14:35 abc140212095658.dat
-rw-r--r--    0 600598020 600598020       27 Feb 16 14:35 abc140212095710.dat
-rw-r--r--    0 600598020 600598020       40 Feb 16 14:35 abc140212095719.dat
-rw-r--r--    0 600598020 600598020       52 Feb 16 14:35 abc14022012.dat
-rw-r--r--    0 600598020 600598020        0 Feb 16 14:32 b.dat
-rw-r--r--    0 600598020 600598020        0 Feb 16 14:32 c.dat
-rw-r--r--    0 600598020 600598020        0 Feb 16 14:32 d.dat

##############################################

and selecting their name and size will get -
###############################
Code:
a.dat|0
abc140212095613.dat|21
abc140212095639.dat|25
abc140212095648.dat|43
abc140212095658.dat|35
abc140212095710.dat|27
abc140212095719.dat|40
abc14022012.dat|52
b.dat|0
c.dat|0
d.dat|0

###############################

But I don't want the details of a.dat, b.dat, c.dat and d.dat.

Regards,
Bijitesh

Last edited by Franklin52; 02-17-2012 at 03:30 AM.. Reason: Please use code tags for code and data samples, thank you
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk's variable in regular expression

Anyone know how I will use awk's variable in a regular expression? This line of code of mine is working, the value PREMS should be a variable: awk '$1 ~ /PREMS/ { if(length(appldata)+2 >= length($1)) print $0; }' appldata=$APPLDATA /tmp/file.tmp The value of APPLDATA variable is PREMS. ... (2 Replies)
Discussion started by: Orbix
2 Replies

2. Shell Programming and Scripting

AWK - compare $0 to regular expression + variable

Hi, I have this script: awk -v va=45 '$0~va{print}' flo2 That returns: "4526745 1234 " (this is the only line of the file "flo2". However, I would like to get "va" to match the begining of the line, so that is "va" is different than 45 (eg. 67, 12 ...) I would not have any output. That... (3 Replies)
Discussion started by: jolecanard
3 Replies

3. 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

4. UNIX for Advanced & Expert Users

Regular expression / regex substition on Unicode text

I have a large file encoded in Unicode that I need to convert to CSV. In general, I know how to do this by regular expression substitutions using sed or Perl, but one problem I am having is that I need to put a quotation mark at the end of each line to protect the last field. The usual regex... (1 Reply)
Discussion started by: thomas.hedden
1 Replies

5. Shell Programming and Scripting

awk + pattern search with regular expression

Hi , I have a file with "|" (pipe) as a delimeter. I am looking for the record count where 5th field is a number with 15 digit length only. all the records with above requirement is valid rest all are invalid. I need count of valid records and invalid records. Can anyone please help (9 Replies)
Discussion started by: vikash_k
9 Replies

6. Shell Programming and Scripting

Passing Variable to Regular Expression

Hi All, Below is a sample code: print "Enter the Name: "; my $Name = <>; print "Word is $Name"; open (FH,"AIDNameList.txt"); while (<FH>) { my $line; print "Word is $Name"; for $line(<FH>)... (12 Replies)
Discussion started by: jisha
12 Replies

7. Shell Programming and Scripting

How can awk search a string without using regular expression?

Hello, Awk seem treat the pattern as regular expression, how can awk search not using regular expression? e.g. just represent for "", not "A" or "a" . I don't want to add backslash . (2 Replies)
Discussion started by: 915086731
2 Replies

8. 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

9. Shell Programming and Scripting

Passing regular expression to nawk

I am trying to test if I can replace a regular expression in 'nawk' with a variable. Please let me know why it is not working. I am using ksh88i on solaris8 I am trying use this test as a building block to filter active external DNS connections. Ideally I want to pass variable defined... (4 Replies)
Discussion started by: kchinnam
4 Replies

10. Shell Programming and Scripting

awk regular expression search

Hi All, I would like to search a regular expression by passing as an i/p variableto AWK. For Example :: 162.111.101.209.9516 162.111.101.209.41891 162.111.101.209.9516 162.111.101.209.9517 162.111.101.209.41918 162.111.101.209.9517 162.111.101.209.41937 162.111.101.209.41951... (7 Replies)
Discussion started by: Girish19
7 Replies
ARP2ETHERS(8)						      System Manager's Manual						     ARP2ETHERS(8)

NAME
arp2ethers - convert arpwatch address database to ethers file format SYNOPSIS
arp2ethers DESCRIPTION
arp2ethers converts file arp.dat in the current directory into ethers(5) format on stdout. Usually arp.dat is an ethernet/ip database file generated by arpwatch(8). The arpwatch daemon in Debian will create different arp.dat depending on its configuration. All of them will be available at /var/lib/arpwatch/. FILES
/var/lib/arpwatch - default directory for arp.dat arp.dat - ethernet/ip address database SEE ALSO
arpwatch(8), ethers(5), rarp(8), arp(8), BUGS
Please send bug reports to arpwatch@ee.lbl.gov. AUTHORS
Original version by Craig Leres of the Lawrence Berkeley National Laboratory Network Research Group, University of California, Berkeley, CA. Modified for the Debian Project by Peter Kelemen, with additions from Erik Warmelink. The current version is available via anonymous ftp: ftp://ftp.ee.lbl.gov/arpwatch.tar.gz This manual page was contributed by Hugo Graumann. ARP2ETHERS(8)
All times are GMT -4. The time now is 05:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy