Execution problems using awk command.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execution problems using awk command.
# 1  
Old 08-11-2009
Execution problems using awk command.

Hi All,

I have the following requirement. In a directory i get files from external source. I at regular intervals check that directory for any incoming files.
The file name is underscore delimited.
Such as:

aaa_bbb_ccc_ddd_eee_fff.dat

I am using awk and and splitting the file name.

But now we are getting files with an extra parameter too.

aaa_bbb_ccc_ddd_eee_fff_ggg.dat

so there may be a combination of files with diferent field counts. So i am unable to parse the file name coz i dont know the exact field count as it may change for different file names Smilie.

I googled and i found out that optional parameters can be made use of in GAWK. But i need to know how to do it using awk. Any alternative apart from GAWK, awk(if not possible using awk) is also welcomed. Any help would be greatly appreciated.
# 2  
Old 08-11-2009
You said:
HTML Code:
I am using awk and and splitting the file name.
Post that code, not sure what your requirement is.
# 3  
Old 08-11-2009
Code used by me

The code i am using for splitting filename using awk is :

awk -F "_" ' {$1"_"$2"_"$3"_"$4"_"$5"_"$6} '


I need to incorporate for extra $7 if a file with 7 fields arrives.

Is this enough or did i miss any clarity? So problem occurs if in the directory both files with 6 and 7 fields exists.
# 4  
Old 08-11-2009
Pls , Post exact input and the output your expecting .
# 5  
Old 08-16-2009
Thanks friends. I got the solution.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execution Problems with awk

Ubuntu, Bash 4.3.48 Hi, I have this input file: a1:b2:c30:g4:h12:j7 and I want this output file: a1=g4:b2=h12:c30=j7 I can do it this with this code: awk -F':' '{print $1"="$4":"$2"="$5":"$3"="$6"}' INPUT > OUTPUTIn this case I have 6 columns, I calculate manually the half number of... (6 Replies)
Discussion started by: echo manolis
6 Replies

2. Shell Programming and Scripting

Execution Problem with awk command

Hi All, I am trying to find a word from a file in loop. while read i; do DB_Name=$i awk '{for(i=1;i<=NF;i++)if($i~/$DB_Name/)print $(i)}' $BTEQ_NAME > $DB_Name_TableList.txt done <Param.txt here Param.txt contents data as ODS_TARGT_RECV FIN_TARGT... (7 Replies)
Discussion started by: Shilpi Gupta
7 Replies

3. Shell Programming and Scripting

Multiple command execution inside awk command during xml parsing

below is the output xml string from some other command and i will be parsing it using awk cat /tmp/alerts.xml <Alert id="10102" name="APP-DS-ds_ha-140018-componentFailure-S" alertDefinitionId="13982" resourceId="11427" ctime="1359453507621" fixed="false" reason="If Event/Log Level(ANY) and... (2 Replies)
Discussion started by: vivek d r
2 Replies

4. UNIX for Dummies Questions & Answers

Dsh command : Execution Problems with Cron

Hi, On linux cluster, i created a script to delete all temp files older than 5 days. i am able to execute the script "dsh -ea script.ksh" in management node directly But when i schedule "dsh -ea script.ksh" in crontab in management node it tells dsh command not found. How to solve... (2 Replies)
Discussion started by: smartrajusid
2 Replies

5. Shell Programming and Scripting

Execution Problems

this my source file ************* fixed *************** Begin equipmentId : d9 processor : fox number : bhhhhhh Variable # 1: Id : 100 Type : 9 nType : s gType : 5f mType : 4 LField : England DataField : london Length ... (6 Replies)
Discussion started by: teefa
6 Replies

6. Shell Programming and Scripting

Execution Problems!!

i have been working on this for a about 12 hours today say's end of file un expected any idea's using the bourne shell and its driving me nuts worked fine in bash but prof says make it work in bourne and good luck worth 13% any help would be awesome #!/bin/sh trap "rm mnt2/source/tmp/* 2>... (1 Reply)
Discussion started by: mrhiab
1 Replies

7. Shell Programming and Scripting

Execution problems with grep command in scripting

Hi All, I was looking for grep command option which can exactly matches the word in a file, for examples you may be seeing one word that is also in another word, there might be lkk0lv23 and a lkk0lv234 in which case lkk0lv23 will put BOTH hosts from the grep in. I was using this in a bash... (2 Replies)
Discussion started by: bobby320
2 Replies

8. Shell Programming and Scripting

Execution problems with the jar -tvf command and "if" logic

Hi, I am reading a directory that has a list of jar files. I am searching these files for specific keywords. What i would like to do is write the address of the jar file to a new file if the search result is returned as false. For example; /home/user/JarDirectory/Examplefile.jar ... (2 Replies)
Discussion started by: crunchie
2 Replies

9. Shell Programming and Scripting

Execution problems with comm command

I tried to compare two sorted files with comm command which contain floating values as: RECT 0 9.8 8.70 7.8 in first file & RECT 0 9.80 8.7 7.80 in second file. comm -3 first_file second_file should give a empty file but it does not. Is there a way to compare these two files correctly... (4 Replies)
Discussion started by: nehashine
4 Replies

10. Shell Programming and Scripting

Execution of awk command in a variable

Hi All, I have a awk command that is stored in a variable. the value of the variable cmd is: (mean output of echo $cmd is: ) awk -F";" '{print $1}' Now I want to execute this command. How can I do that???? Quick Reply will be appreciated. Regards, Amit (2 Replies)
Discussion started by: patelamit009
2 Replies
Login or Register to Ask a Question