awk, sed, grep...weird style


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk, sed, grep...weird style
# 1  
Old 05-16-2008
awk, sed, grep...weird style

Quote:
AutoMicro Job Request
================================
(1). Job Request Information
================================
Date of Request: 20080514 10:36 Submitted By: name
First Carrier: carrier name (612W) Date of Process: 20080514 10:36

================================
(2). Plan Summary By Connection
================================
| Previous | | Current |
Conn Total Plan Usr Prev Can Has
*some space* Vsl Voy Type Qty Qty Plan Plan Plan Plan Reason**
--- --- ---- ----- --- ---- ---- ---- ---- ------
vessel name 6113A HLDITH 23 0 0 0 23 23
**Reason: [P]: Cannot Plan Fully [O]: Not In Planning Scope [C]: No Cluster
[B]: Big Volume [I]: Band 1 HLD Connection [S]: Not Selected
[N]: No BKDN to Plan [H]: Holding Volume Too High [F]: No Feasible space

==========================================
(3). Plan Details For Connecting Carriers
==========================================
Vsl Voy Port Sz Cat Wt Block Slot Row Qty Crane OperCode ResvFor
carrier name 6113A xxxx 40 GP M U02 25 8 1 0
*some space* xxxx 40 HC M U02 25 8 1 0
*some space* xxxx 40 HC H U02 25 7 3 0
*some space* xxxx 40 HC H U02 25 8 3 0
*some space* xxxx 20 GP X U02 27 8 2 0
*some space* xxxx 20 GP M U02 27 8 1 0
*some space* xxxx 20 GP U U02 27 4 4 0
*some space* xxxx 20 GP U U02 27 5 5 0
*some space* xxxx 20 GP U U02 27 8 3 0

================================
(4). Free Space Summary
================================

my desired output is like this:

so the thing is, I only need to show every of this part out
Quote:
xxxx 40 GP M U02 25 8 1 0
xxxx 40 HC M U02 25 8 1 0
xxxx 40 HC H U02 25 7 3 0
xxxx 40 HC H U02 25 8 3 0
xxxx 20 GP X U02 27 8 2 0
xxxx 20 GP M U02 27 8 1 0
xxxx 20 GP U U02 27 4 4 0
xxxx 20 GP U U02 27 5 5 0
xxxx 20 GP U U02 27 8 3 0
but the frequency of that data is not fixed, so sometimes it may have 4 lines, or 6 lines or whatever in that file. However, the last line will always have empty space/line below it.

Last edited by finalight; 05-16-2008 at 06:07 AM..
# 2  
Old 05-16-2008
What's a good criterion for identifying those lines?

Code:
grep xxxx file

# 3  
Old 05-16-2008
pass your output result to sed

Code:
sed 's/^ *//'

# 4  
Old 05-16-2008
Quote:
Originally Posted by era
What's a good criterion for identifying those lines?

Code:
grep xxxx file

they are one single word, but may not be similiar
# 5  
Old 05-16-2008
Quote:
Originally Posted by aju_kup
pass your output result to sed

Code:
sed 's/^ *//'

huh? i don't get your meaning
# 6  
Old 05-16-2008
cat file | grep xxx | awk -F"*" '{ print $2 }'
# 7  
Old 05-16-2008
Useless Use of Cat! Useless Use of Grep | Awk!

Code:
awk -F "*" '/xxx/ { print $2 }' file

I don't think that does what was requested, though. I'm not sure, however; it would still help to get a sample of the expected output.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

changing c comments to c++ style with sed

Hi everyone, I've got a problem with converting C comments ( /* */ ) into C++ style ( // ) in some source file with sed. So far I've dealt with comments on one line, but I don't know how to convert when it is over multiple lines ... So I already have something like this: comments.sed ... (8 Replies)
Discussion started by: kolage
8 Replies

2. UNIX for Dummies Questions & Answers

grep/awk/sed?

Thread1 { x = 2 y = 10485 } Thread2 { x = 16 y = 1048 } Thread3 { x = 1 y = 1049 } Thread4 { x = 4 y = 1047 z = 500 } Suppose the above is a piece of code. I need to automate and verify that the value of x under Thread1's 2. There are several... (3 Replies)
Discussion started by: foxtron
3 Replies

3. Shell Programming and Scripting

help using sed/awk/grep

thanks for your reply. but i'm not quite sure what your code is doing. i may be using it wrong but i'm not getting what i'm supposed to get. could you please elaborate? thanks again, (6 Replies)
Discussion started by: kratos.
6 Replies

4. Shell Programming and Scripting

grep or awk or sed not sure which to use here

Hi All, I have a huge file, I need to two things from this file. I need to know the IP address or the hostname and second thing is the date&time. The file looks like this and I need to get my data from this... Trying... Connected to 204.109.172.117. Escape character is '^]'. Fri... (4 Replies)
Discussion started by: samnyc
4 Replies

5. UNIX for Dummies Questions & Answers

How could i get this by sed or grep or awk ????

------------------------------------------------------------------ Ex of Warning messgae,(Many similar lines occure for Both Test and Test1) -WARNING:Below Field not implemented in file File name: /home/test/ new/file1, msg buffer is: :Test:000948 ... (1 Reply)
Discussion started by: prsam
1 Replies

6. UNIX for Dummies Questions & Answers

Grep Sed or Awk?

I have two .txt files one called good.txt and the other one is called bad.txt. Both contain email addresses in the following format: john@john.com bob@bob.com sarah@sarah.com Basically, I want to scrub good.txt against bad.txt and save the resulting output in scrubbed.txt meaning that if... (2 Replies)
Discussion started by: holyearth
2 Replies

7. Shell Programming and Scripting

Sed | Awk | Grep

Can someone help me in understanding when to use SED, AWK and GREP (3 Replies)
Discussion started by: kn.naresh
3 Replies

8. Shell Programming and Scripting

weird behavior of grep -P

I met a problem in using grep -P. There is a text file, temp.txt, whose content is: dddd abc I ran the command: grep -P "\s*abc" temp.txt The result I expected is: abc But, the actual result is: dddd abc Could anyone tell me what is wrong? Thanks. (2 Replies)
Discussion started by: pankai
2 Replies

9. Shell Programming and Scripting

need help!!!awk,grep,sed

hi all by using cat /etc/passwd I've got these output. ajh1ect:x:839:501:Anthony:/home/ajh1ect:/bin/bash mjb1ect:x:840:501:Michael:/home/mjb1ect:/bin/bash mv3ect:x:841:501:Marian:/home/mv3ect:/bin/bash now I want to see just the user ID and group ID. so what is the code will be with... (2 Replies)
Discussion started by: nokia1100
2 Replies
Login or Register to Ask a Question