Mombu the Programming Forum

Go Back   Mombu the Programming Forum > Programming > construct the filename to process??
User Name
Password
REGISTER NOW! Mark Forums Read




Reply Bookmark and Share
1 10th November 02:14
atropo
External User
 
Posts: 1
Default construct the filename to process??



Newbie. I posted this before but had not realize how to accomplish.

have this file. input.txt

8092261513 4473.19OUT COMP20060905R1
8092410453 1105.92OUT COMP20060905R1
8092411018 3955.57OUT COMP20060904R1
..
..

the third field has a date "20060905"
the files of that date are:

OUT-20060905-041813.1.out
OUT-20060905-041844.1.out
OUT-20060905-045941.1.out
OUT-20060905-050150.1.out
..
..
I have to format the first field to look for it on those files of that
date..

qnt=(substr($1,1,3)"-" substr($1,4,3)"-" substr($1,7,10)) {print t} .

Ed Morton kindly showme this
awk -v RS="." -v FS=""
' NR=FNR{tels[$t];next}
$t in tels { "wich variables from second files?" }
' file1.txt OUT-20060905-041813.1.out

but i guess this is when you had passed the second filename as
parameter
here file1.txt has the formated number and using specific second
filename.

If i have a part of string of filename... "20060905" how could I

1.construct a unique file to process, maybe using cat inside awk..
2.process all files that matches

after all this how could I reference the data of the second file that
matches de values of first file??
very very lost. but I'm RTFM
  Reply With Quote


 


2 10th November 02:14
ed morton
External User
 
Posts: 1
Default construct the filename to process??



I think what you're saying is that you want to read input.txt and use
that to:

a) from $3 derive the file names for subsequent processing, and
b) from $1 derive the string to search for in those subsequent files.

Since you refer to "cat" it seems like you're using UNIX so the simplest
solution would involve a mixture of awk and shell and so would be
somewhat OT here and more appropriate for comp.unix.shell but I'll risk
the flames this time in case I've misunderstood what you want:

I also think your final "substr()" whoud be substr($1,7,3) instead of
substr($1,7,10).

If all of the above is correct, one approach would be:

awk '{
qnt = substr($1,1,3) "-" substr($1,4,3) "-" substr($1,7,3)
gsub(/[^[:digit:]]/,"",$3)
print qnt, $3
}' input.txt |
while read qnt date
do
awk -v qnt="$qnt" '$0 ~ qnt{print FILENAME, qnt, $0}' OUT-*"$date"*
done

The above assumes you want to output the FILENAME, pattern searched for
and matching record. Adjust to suit.

Regards,

Ed.
  Reply With Quote
3 19th November 13:31
atropo
External User
 
Posts: 1
Default construct the filename to process??


Ed Morton ha escrito:


Thanks Ed. exactly what I want. but I guess my awk doesn't support
[:digit:]. don't know either what version is. well the one that
comes with aix 5.2
Anyway a lot of thanks.
  Reply With Quote
Reply


Thread Tools
Display Modes


Some other forums that might be of your interest : Development, Ada, Apple script, Assembler, Awk, Beos, Basic, C, C++, C#, C# .net, .net, .net frameworks, Asp .net, Clarion, Clipper, Clos, Clu, Cobol, Coldfusion, Delphi, Dylan, Eiffel, Forth, Fortran, Haskell, Hermes, Icon, Idl, Java, Java script, Jscript .net, Jcl, Linoleum, Lisp, Lotus, Limbo, Logo, Ml, Mumps, Oberon, Postscript, Pop, Pl1, Prolog, Python, Ruby, Pascal, Perl, Php, Rebol, Rexx, Sed, Sather, Scheme, Smalltalk, Tcl, Vhdl, Vrml, Visual basic, Visual basic .net, Yorick, Mysql, Omnis, Postgresql, Xbase, Access, Oracle, Adabas, Berkeley, Btrieve, Filemaker, Gupta, Db2, Informix, Ingres, Mssql server, Object, Olap, Paradox, Rdb, Revelation, Sybase, Theory, Dbase, Html, Java script, Css, Flash, Photoshop, Corel script, Xml, Tech, Beos, Gem, Hp48, Hpux, Linux, Mac, Ms-dos, Os2, Palm, Solaris, Ti99, Windows, Xenix, Aos, Chorus, Geos, Inferno, Lantastic, Lynx, Mach, Minix, Netware, Os9, Parix, Plan9, Psos, Qnx, Xinu, Sco, Unix, Aix, Aux, 386bsd, Bsdi, Freebsd, Netbsd, Openbsd, Ultrix, Amd, Intel, Aptiva, Buz, Deals, Homebuilt, Overclocking, Programming, Extra forums


Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666