Script programming help with AWK


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script programming help with AWK
# 1  
Old 11-30-2010
Script programming help with AWK

I've scripting code issue by using with AWK command. My existing command in the script is,
Code:
for i in `find ${INPUTDIR} -maxdepth 1 -iname XYZ_??_${PLACE}_*.${SUFFIX} | awk -F'/XYZ_' '{print "XYZ_"$2}'`

But here instead of the letter "Z", the new files are coming with XYA, XYB, and XYC as well. So my loop condition should be,
Code:
for i in `find ${INPUTDIR} -maxdepth 1 -iname XY?_??_${PLACE}_*.${SUFFIX} | awk -F'/XYZ_' '{print "XYZ_"$2}'`

From above "for" loop I am unable to write the awk condition to find out the files with XYA, XYB and XYC in my script. How to I find with wild card by using awk command here. Can anyone help me out in this?

I am using LINUX o/s.

Last edited by jim mcnamara; 11-30-2010 at 12:24 PM.. Reason: code tags please
# 2  
Old 11-30-2010
-F '/XYZ'

means that the / character is a field separator all by itself, so are X and Y and Z

Was that you wanted?
# 3  
Old 11-30-2010
try below:-

Code:
for i in `find ${INPUTDIR} -maxdepth 1 -iname XY?_??_${PLACE}_*.${SUFFIX} | awk '{print FS $2}'` FS="XY[ABCZ]_"

BR
# 4  
Old 11-30-2010
Thanks for all replies. The above trial was not working in my script.

But I would like to give up in another way of my programming issue as below. The for loop is:

for i in `find ${INPUTDIR} -maxdepth 1 -iname XYZ_??_${PLACE}_*.${SUFFIX} | awk -F'/REZ_' '{print "REZ_"$2}'`

From above condition, the condition is fit for only the file which are contains "REZ_" only. But there are the files other than "REZ_" like "RES_", "RET_" and "REX_". By using above for loop, how do I check other than "REZ_"? I am unable to write the script condition here.

I am able to give the find statement by using LINUX command but unable to fix with AWK programming.

for i in `find ${INPUTDIR} -maxdepth 1 -iname RE?_??_${PLACE}_*.${SUFFIX} | awk -F'/REZ_' '{print "REZ_"$2}'`
# 5  
Old 11-30-2010
For my understand, you need get the file name only

Code:
for i in `find . -maxdepth 1 -iname XY?_??_*_*.ttt -exec basename {} \; `

Code:
for i in `find . -maxdepth 1 -iname REZ_??_*_*.ttt -exec basename {} \; `

# 6  
Old 12-01-2010
Would like to know whether possible to check with wildcard files by using AWK? From the above "for" loop statement, can't we use "?" instead of by given "REZ_" can use "RE?_". Any ideas?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk programming -Passing variable to awk for loop

Hi All, I am new to AWK programming. I have the following for loop in my awk program. cat printhtml.awk: BEGIN -------- <some code here> END{ ----------<some code here> for(N=0; N<H; N++) { for(M=5; M<D; M++) print "\t" D ""; } ----- } ... (2 Replies)
Discussion started by: ctrld
2 Replies

2. Shell Programming and Scripting

awk programming

Need assistance using awk . Need assistance in awk programming. Any idea of getting the marked data into a file. </tr> <tr> <td class='labelOptional_ind'> cdr.00012325.0000000000000000.20130612.050005.WANP4722_csv </td> <td width='15%' class='labelOptional'> <div align='center'>... (8 Replies)
Discussion started by: ajayram_arya
8 Replies

3. Programming

awk programming

I have the list of numbers in a file 105.1 102.0 100.5 100 98 97.5 95 ... I want to get how many times I have numbers greater than a particular limit, say 100 in the list. How can I do that with awk command? (5 Replies)
Discussion started by: pranto_d
5 Replies

4. Shell Programming and Scripting

awk programming

Good morning to everyone! guys, help me please I have a file like this one: diamond 5 7.8 77777765 1 7 1234567890 9 3.5 diamond 2 1 1234567890 3 6.8 77777765 0 4 os Solaris it's only example, columns may be more, but in my case only 3 columns so, my question how I can group... (1 Reply)
Discussion started by: shizik
1 Replies

5. UNIX for Dummies Questions & Answers

awk programming

Good morning! guys, help me please I have a file like this one: diamond 5 7.8 77777765 1 7 1234567890 9 3.5 diamond 2 1 1234567890 3 6.8 77777765 0 4 os Solaris it's only example, columns may be more, but in my case only 3 columns so, my question how I can group according to... (1 Reply)
Discussion started by: shizik
1 Replies

6. Shell Programming and Scripting

awk programming

Hi I have a multi -line file which is sorted by the 1-st colomn in the following format: 400 0000 0001 1000 1010 0111 0000 1000 0000 402 1101 0000 1100 1010 0111 1000 1000 0000 403 1001 0000 1100 1010 0111 0000 1000 0000 495 1000 0000 1100 ... (4 Replies)
Discussion started by: aoussenko
4 Replies

7. UNIX for Dummies Questions & Answers

awk (?) programming

Hello i need help with following problem: i need to update a file containing records in following format: student1 classa student2 classb student3 student4 classc i need to associate EACH student with a class in my output file ... so for students 3 and 4, i need to create a... (12 Replies)
Discussion started by: alrinno
12 Replies

8. Shell Programming and Scripting

need help with awk programming

Hello Friends I want to process only those lines which are not started with a * or " example File name: GRX "RxDataTime, NSysClkEn, Frame","Size","Sleep","TNum","TSet","TWait" *Init Start *Comment Generated from: C:\Documents and Settings 000000,0000,1,0,0,0,0,0,0... (8 Replies)
Discussion started by: user_prady
8 Replies

9. Shell Programming and Scripting

awk programming

Hi all, i want to study harder awk programming. where can i get a good examples, problems and solutions. i'm in a hurry.. thanks, (5 Replies)
Discussion started by: tungaw2004
5 Replies

10. Shell Programming and Scripting

awk programming

Hi folks, I would like to know the difference between shell programming and awk programming. Actually i have developed a few applications in both but i could not find a better difference other than the syntax differences. For example, the awk programming syntax is complicated. It has "{" and... (4 Replies)
Discussion started by: Nisha
4 Replies
Login or Register to Ask a Question