Sponsored Content
Full Discussion: help parsing txt with awk
Top Forums Shell Programming and Scripting help parsing txt with awk Post 302365257 by yomaya on Monday 26th of October 2009 12:59:47 PM
Old 10-26-2009
help parsing txt with awk

Hi all

I would need some help to introduce 'break' lines into the following
data by using awk:

original data:
Code:
RECORD 1000 aaa xxxxxx
RECORD 1001 aaa xxxxxx
RECORD 1002 bbb xxxxxx
RECORD 1003 bbb xxxxxx
RECORD 1004 bbb xxxxxx
RECORD 1005 ccc xxxxxx
RECORD 1006 ccc xxxxxx
RECORD 1007 ddd xxxxxx
RECORD 1008 ddd xxxxxx
RECORD 1009 ddd xxxxxx
RECORD 1010 ddd xxxxxx
RECORD 1011 eee xxxxxx
RECORD 1012 eee xxxxxx
RECORD 1013 eee xxxxxx
RECORD 1014 eee xxxxxx

desired output:
Code:
RECORD 1000 aaa xxxxxx
RECORD 1001 aaa xxxxxx
RECORD 1002 bbb xxxxxx
RECORD 1003 bbb xxxxxx
RECORD 1004 bbb xxxxxx
RECORD 1005 ccc xxxxxx
RECORD 1006 ccc xxxxxx
break
RECORD 1007 ddd xxxxxx
RECORD 1008 ddd xxxxxx
RECORD 1009 ddd xxxxxx
RECORD 1010 ddd xxxxxx
break
RECORD 1011 eee xxxxxx
break
RECORD 1012 eee xxxxxx
break
RECORD 1013 eee xxxxxx
break
RECORD 1014 eee xxxxxx
break

The point is that I'm not able to process it properly
with awk, so I would need some help...

Code:
awk '{ if( $3 ~ /ddd/ )                                     
       { while ( $3 == "ddd" )                               
         { getline; print $0 }                             
           print "break"
         }                             
       else if( $3 ~ /eee/ )
         { print $0 }
       else { print $0 }
     }' file.dat > new_file.dat

Thanks in advance.

Last edited by yomaya; 10-26-2009 at 02:21 PM.. Reason: code tags, please!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

echo "ABC" > file1.txt file2.txt file3.txt

Hi Guru's, I need to create 3 files with the contents "ABC" using single command. Iam using: echo "ABC" > file1.txt file2.txt file3.txt the above command is not working. pls help me... With Regards / Ganapati (4 Replies)
Discussion started by: ganapati
4 Replies

2. Shell Programming and Scripting

AWK CSV to TXT format, TXT file not in a correct column format

HI guys, I have created a script to read 1 column in a csv file and then place it in text file. However, when i checked out the text file, it is not in a column format... Example: CSV file contains name,age aa,11 bb,22 cc,33 After using awk to get first column TXT file... (1 Reply)
Discussion started by: mdap
1 Replies

3. Shell Programming and Scripting

awk-files in a txt

There is a file that contains access's data to a web server. Each line of the file (it's big) it's : IP Client - - "Command Path Protocol" code size "client software" Example,for the first line: IP Client is 67.195.37.107, date-hour is , Command Path Protocol is "Get /papers/ISO4nm.pdf ... (1 Reply)
Discussion started by: Mark_orig
1 Replies

4. Shell Programming and Scripting

parsing txt file, saving graphics files

hi everyone, i am a newbie in shell programming. and i want to simply go through a text file that contains 3 "columns", split by ';' customerID ; link-to-contract ; save-as-filename so an example would simply look like this now i want to loop through every line, and save the file from... (3 Replies)
Discussion started by: Confidence
3 Replies

5. Shell Programming and Scripting

Parsing txt, xml files and preparing csv file

Hi, I need to parse text, xml files to get the statistic numbers and prepare summary csv file. What is the best way to parse these file and prepare csv file. Any idea you have , please? Regards, (2 Replies)
Discussion started by: LinuxLearner
2 Replies

6. Shell Programming and Scripting

awk append fileA.txt to growing file B.txt

This is appending a column. My question is fairly simple. I have a program generating data in a form like so: 1 20 2 22 3 23 4 12 5 43 For ever iteration I'm generating this data. I have the basic idea with cut -f 2 fileA.txt | paste -d >> FileB.txt ???? I want FileB.txt to grow, and... (4 Replies)
Discussion started by: theawknewbie
4 Replies

7. Windows & DOS: Issues & Discussions

Parsing a UNIX txt to separate files

I have a requirement to parse a dataflex .txt file and break it into separate files within the Windows server env. Is there any special characters I should pay particular attention on the unix side? Any ideas? Thanks in advance (2 Replies)
Discussion started by: kicklinr
2 Replies

8. Shell Programming and Scripting

Desired output.txt for reading txt file using awk?

Dear all, I have a huge txt file (DATA.txt) with the following content . From this txt file, I want the following output using some shell script. Any help is greatly appreciated. Greetings, emily DATA.txt (snippet of the huge text file) 407202849... (2 Replies)
Discussion started by: emily
2 Replies

9. Shell Programming and Scripting

Parsing a txt file according to two different tags

I need to parse a txt file like below. starts from the first occurence of SASN2010Aber.CallEventRecord.egsnPDPRecord { till the last occurence of } in other saying name of the part(header) is SASN2010Aber.CallEventRecord.egsnPDPRecord and the content of the header is in two... (3 Replies)
Discussion started by: snr_silencer
3 Replies

10. Shell Programming and Scripting

Awk, sed, shell all words in INPUT.txt find in column1 of TABLE.txt and replce with column2 in

Hi dears i have text file like this: INPUT.txt 001_1_173 j nuh ]az 001_1_174 j ]esma. nuh ]/.xori . . . and have another text like this TABLE.txt j j nuh word1... (6 Replies)
Discussion started by: alii
6 Replies
kpasswd(1)							   User Commands							kpasswd(1)

NAME
kpasswd - change a user's Kerberos password SYNOPSIS
/usr/bin/kpasswd [principal] DESCRIPTION
The kpasswd command is used to change a Kerberos principal's password. kpasswd prompts for the current Kerberos password, which is used to obtain a changepw ticket from the KDC for the user's Kerberos realm. If kpasswd successfully obtains the changepw ticket, the user is prompted twice for the new password, and the password is changed. If the principal is governed by a policy that specifies the length and/or number of character classes required in the new password, the new password must conform to the policy. (The five character classes are lower case, upper case, numbers, punctuation, and all other charac- ters.) OPERANDS
The following operand is supported: principal Change the password for the Kerberos principal principal. Otherwise, the principal is derived from the identity of the user invoking the kpasswd command. FILES
/tmp/ovsec_adm.xxxxxx Temporary credentials cache for the lifetime of the password changing operation. (xxxxxx is a random string.) ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWkrbu | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ SEE ALSO
SEAM(5) BUGS
If kpasswd is suspended, the changepw tickets may not be destroyed. SunOS 5.10 30 Jul 2001 kpasswd(1)
All times are GMT -4. The time now is 06:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy