Help with awk (making simple/advanced ini parser)


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with awk (making simple/advanced ini parser)
# 15  
Old 07-18-2011
What does this show:
Code:
awk '/Weapon_DmgType_0=1/&&/Weapon_DmgType_0=2/' RS= weapon.fopro

# 16  
Old 07-18-2011
Same, it just print whole that file, because there is even Weapon_DmgType_0=7
Strange, that it worked with example file ([something]). Did it done normally for you? Or not too?
# 17  
Old 07-18-2011
Can you post output of:
Code:
cat -eT weapon.fopro | head -50

This User Gave Thanks to bartus11 For This Post:
# 18  
Old 07-18-2011
Code:
 cat -eT weapon.fopro | head -50
[Proto]^M$
ProtoId=4^M$
Type=3^M$
PicMap=art\items\knife.frm^M$
PicInv=art\inven\oknife.frm^M$
Flags=134217758^M$
DisableEgg=1^M$
Deteriorable=1^M$
Weight=453^M$
Volume=1^M$
SoundId=51^M$
Cost=40^M$
Material=1^M$
Weapon_Anim1=4^M$
Weapon_MinStrength=2^M$
Weapon_ActiveUses=3^M$
Weapon_CriticalFailture=1^M$
Weapon_Skill_0=204^M$
Weapon_Skill_1=204^M$
Weapon_Skill_2=200^M$
Weapon_DmgType_0=1^M$
Weapon_DmgType_1=1^M$
Weapon_PicUse_0=art\intrface\swing.frm^M$
Weapon_PicUse_1=art\intrface\thrust.frm^M$
Weapon_PicUse_2=art\intrface\blank.frm^M$
Weapon_DmgMin_0=1^M$
Weapon_DmgMin_1=1^M$
Weapon_DmgMax_0=6^M$
Weapon_DmgMax_1=6^M$
Weapon_MaxDist_0=1^M$
Weapon_MaxDist_1=1^M$
Weapon_ApCost_0=3^M$
Weapon_ApCost_1=3^M$
Weapon_Aim_0=1^M$
Weapon_Aim_1=1^M$
Weapon_SoundId_0=51^M$
Weapon_SoundId_1=51^M$
^M$
[Proto]^M$
ProtoId=5^M$
Type=3^M$
PicMap=art\items\club.frm^M$
PicInv=art\inven\club.frm^M$
Flags=134217758^M$
DisableEgg=1^M$
Stackable=1^M$
Weight=1360^M$
Volume=2^M$
SoundId=48^M$
Cost=30^M$

Here it is.
# 19  
Old 07-18-2011
Before executing your AWK code run this:
Code:
dos2unix weapon.fopro

Run it for every file that you transfer from Windows machine Smilie
This User Gave Thanks to bartus11 For This Post:
# 20  
Old 07-18-2011
One more strange thing, before I typed this command dos2unix I tried to show number of blocks with:
Code:
awk '{print NR}' RS= weapon.fopro

and it responded me with only one 1, now after it, it shows me 129 of this

Yes, now it's working correctly, so it seems that it was just wrong encoding?
And one more thing, because output seems, that it doesn't have free line (after last line of first block there is next one, there isn't empty line)
Anyway, big thanks, without You I won't get succes.

And also, for filtering second thing I have to put &&, but how about OR, I mean, can I do it something like this?
Weapon_Anim1=8
Code:
awk '/Weapon_DmgType_0=1/&&/Weapon_Anim1=8/OR/Weapon_Anim1=7/' RS= weapon.fopro


Last edited by jormung; 07-18-2011 at 11:31 AM..
# 21  
Old 07-18-2011
The problem was that Windows is using different characters as line breaks. When you transfer the file to Unix/Linux, the file still contain the characters from Windows (^M characters in the output), which are treated as normal characters by all the tools including AWK, so the line that was empty under Windows, now contain ^M character - ^M$ line in the last output. dos2unix is converting all those ^M characters to proper line breaks Unix/Linux tools are expecting.
This User Gave Thanks to bartus11 For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Making a parser

input 1..100km 112..403km 500..623km required output 1..51 112..162 500..550 (i.e 50kms added to the initial distance) (2 Replies)
Discussion started by: ANKIT ROY
2 Replies

2. Shell Programming and Scripting

Java stack trace parser in awk

I want the developers to get a mail with Java stack traces on a daily bases. When something is flaged as known issue and will get a fix but mean while this does not need to get sent each dayl. This is what I got so far. It's a bash script that runs some AWK in it. To get the files that needs to... (6 Replies)
Discussion started by: chipmunken
6 Replies

3. Shell Programming and Scripting

More efficient awk parser

I have an awk parser, that works great if the data is NC_0000 (four digits), but if it is not that then the data is parsed. I'm not sure the most efficient way to obtain the desired output. Thank you :). Code: awk 'FNR > 1 && match($0, /NC_0000(*)\..*g\.(+)(.)>(.)/, a){ print a, a, a, a, a }'... (14 Replies)
Discussion started by: cmccabe
14 Replies

4. Shell Programming and Scripting

Develop a simple command line parser

I want to develop a simple command line parser so that then I can print the values of different options :tions. -analyze -filename<fileName> Via man pages I got to know getopt command would be used. Buut how to use it.. how to encrypt this in a perl script.. grateful if u could help (2 Replies)
Discussion started by: shubhamsachdeva
2 Replies

5. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

6. Shell Programming and Scripting

Advanced AWK Regexp substring to int & Replace

Hi! I have a difficult problem, to step up a unknown version number in a text file, and save the file. It would be great to run script.sh and the version gets increased. Example the content of the textfile.txt hello version = x bye This include three steps 1. First find the char after... (2 Replies)
Discussion started by: Beachboy72
2 Replies

7. Shell Programming and Scripting

Advanced sed/awk help

I have thousands of files in HTML that looks like this: .... .... .... <!-- table horaire --> <!-- table horaire --> <table border="0" cellspacing="0" cellpadding="0" class="tblHoraires" summary="Table des horaires de la ligne 12"> <tr> <th scope="row"... (13 Replies)
Discussion started by: charafantah
13 Replies

8. Shell Programming and Scripting

advanced awk

Hi all Input group1 user1 user2 user3 group2 user4 user5 user1 group3 user6 user7 user8 Desired output group1 group2 (12 Replies)
Discussion started by: wakatana
12 Replies

9. UNIX for Advanced & Expert Users

Simple advanced question

This is a fairly basic advanced question! Does anyone happen to know what level of page faults should be acceptable on a fully operational production system? Useful (?) information: Production system using Oracle database Compaq Tru64 UNIX Server (not sure what model, but it's big!) 8... (14 Replies)
Discussion started by: Neil_mw
14 Replies
Login or Register to Ask a Question