Computing.Net > Forums > Unix > Extracting of data

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Extracting of data

Reply to Message Icon

Name: ex
Date: September 28, 2005 at 06:37:24 Pacific
OS: UNIX
CPU/Ram: 512M
Comment:

Hi Guru's,
here comes another question.

Input:
CBN/C0/68/004NB FSLT Sep 11 19:32:14
CBN/C0/68/004NB FSLT Sep 11 19:32:14
CBN/C0/68/004NB FSLT Sep 11 19:32:14
CBN/C0/68/004NB SLT Sep 11 17:26:31
CBN/C0/68/004NB SLT Sep 11 17:54:40
CBN/C0/68/004NB SLT Sep 11 18:24:37
CBN/C0/68/004NB SLT Sep 11 19:09:54
CBN/C0/68/004NB SLT Sep 11 19:32:14
FA0/91/11/940NB SLT Sep 11 20:13:51
FA0/91/12/025NB SLT Sep 11 20:56:11
FA1/01/02/115NB SLT Oct 10 21:47:14

Output:
CBN/C0/68/004NB SLT Sep 11 19:32:14
FA0/91/11/940NB SLT Sep 11 20:13:51
FA0/91/12/025NB SLT Sep 11 20:56:11
FA1/01/02/115NB SLT Oct 10 21:47:14

If I have a input like that how can I convert to the output I want. I need all the lines starting with FA and only the latest line starting with CBN assuming I can already sort the whole thing in order. I need to cut away those line starting with CBN except the last one before lines starting with FA. The number of CBN lines will varies.

Thanks and Best Regards.




Sponsored Link
Ads by Google

Response Number 1
Name: Jim Boothe
Date: September 28, 2005 at 07:26:34 Pacific
Reply:

Assuming your data is already sorted as you stated, I would use:

csplit -f Output Input '/^FA0/-1'


0
Reply to Message Icon

Related Posts

See More


Simple UNIX script or com... can I use grep command??



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Extracting of data

changing order of data columns? www.computing.net/answers/unix/changing-order-of-data-columns/4558.html

Need help extracting data from file www.computing.net/answers/unix/need-help-extracting-data-from-file/7836.html

sort data www.computing.net/answers/unix/sort-data/7134.html