The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



Thread: reading file
View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 12-07-2004
Lamefif Lamefif is offline
Registered User
 

Join Date: Dec 2004
Posts: 3
reading file

Hi
I ‘m trying to write a simple script that will be able to extract some useful info from a file of this format:

+ 1.84375 0 2 cbr 210 ------- 0 0.0 3.1 225 610
- 1.84375 0 2 cbr 210 ------- 0 0.0 3.1 225 610
r 1.84471 2 1 cbr 210 ------- 1 3.0 1.0 195 600
r 1.84566 2 0 ack 40 ------- 2 3.2 0.1 82 602
+ 1.84566 0 2 tcp 1000 ------- 2 0.1 3.2 102 611
- 1.84566 0 2 tcp 1000 ------- 2 0.1 3.2 102 611
r 1.84609 0 2 cbr 210 ------- 0 0.0 3.1 225 610
+ 1.84609 2 3 cbr 210 ------- 0 0.0 3.1 225 610
d 1.84609 2 3 cbr 210 ------- 0 0.0 3.1 225 610
- 1.8461 2 3 cbr 210 ------- 0 0.0 3.1 192 511
r 1.84612 3 2 cbr 210 ------- 1 3.0 1.0 196 603
+ 1.84612 2 1 cbr 210 ------- 1 3.0 1.0 196 603
- 1.84612 2 1 cbr 210 ------- 1 3.0 1.0 196 603
+ 1.84625 3 2 cbr 210 ------- 1 3.0 1.0 199 612

For example I want to extract the information in column 18-22 but say only the number values (not necessarily all at once).
Using cut utility (i.e. cut –d 18-22 filename) I get

210
210
210
40 -
1000
1000
210
210
210
210
210
210
210
210
But I only need the value without the - character
In other word for each line I need the field value and I cant use [ cut –f ] because there only separated by spaces.
Any ideas or know of a good Unix tutorial for beginners.
Thanks
Reply With Quote
Forum Sponsor