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 -
#################################################
Code:
Connecting to 10.75.112.194...
Changing to: /home/dasd9x/testing1
sftp> mput abc*.dat
Uploading abc140212095613.dat to /home/dasd9x/testing1/abc140212095613.dat
abc140212095613.dat 100% 21 0.0KB/s 00:00
Uploading abc140212095639.dat to /home/dasd9x/testing1/abc140212095639.dat
abc140212095639.dat 100% 25 0.0KB/s 00:00
Uploading abc140212095648.dat to /home/dasd9x/testing1/abc140212095648.dat
abc140212095648.dat 100% 43 0.0KB/s 00:00
Uploading abc140212095658.dat to /home/dasd9x/testing1/abc140212095658.dat
abc140212095658.dat 100% 35 0.0KB/s 00:00
Uploading abc140212095710.dat to /home/dasd9x/testing1/abc140212095710.dat
abc140212095710.dat 100% 27 0.0KB/s 00:00
Uploading abc140212095719.dat to /home/dasd9x/testing1/abc140212095719.dat
abc140212095719.dat 100% 40 0.0KB/s 00:00
Uploading abc14022012.dat to /home/dasd9x/testing1/abc14022012.dat
abc14022012.dat 100% 52 0.0KB/s 00:00
sftp> ls -l
drwxr-xr-x 0 600598020 600598020 1024 Feb 16 14:35 .
drwx------ 0 600598020 600598020 1024 Feb 16 14:34 ..
-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
sftp> quit
#################################################
This log has been captured in a file called sftp_log. Now I am out of the sftp session and I have this sftp_log for my referance. I want to check the log and find out if all the files (resembling abc*.dat) are transferred as per size. So, I want to find the lines where the abc*.dat files were long listed. I have the abc*.dat captured in a variable named TRANSFERRING_FNAME. So I used this variable to be passed in awk and search the desired lines by below command -
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)