LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Manipulating the data in a file (http://www.linuxquestions.org/questions/linux-general-1/manipulating-the-data-in-a-file-4175446133/)

Boopathiraj 01-18-2013 02:47 AM

Manipulating the data in a file
 
All,

Please find the below file...
--------------------------------------
--------------------------------------
Code:

set command
set command a
set command b
set command c
set command d
set command eeasdsda
set policy
set policy a
set policy b
set policy v
set policy x
interface Ethernet0
 speed 100
 duplex full
 nameif ODCLAN
 security-level 100
 ip address 157.227.43.1 255.255.255.0 standby 157.227.43.2
!
interface Ethernet1
 speed 100
 duplex full
 nameif outside
 security-level 0
 ip address 10.0.0.1 255.255.255.248 standby 10.0.0.2

-----------------------------------------------------------
-----------------------------------------------------------

i want to seperate this file into many parts..'
1.From "set command" to "set policy" -- need to put in FILE A

2.From "set policy" to end -- need to have in FILEB

I need to do the above tasks..please suggests.

druuna 01-18-2013 03:49 AM

Assuming that the infile provided is correct (use [code]..[/code] tages to preserve spacing etc), have a look at this:
Code:

awk '/^set command/ { print > "FILEA" } !/^set command/ { print > "FILEB"} ' infile

Boopathiraj 01-25-2013 06:26 AM

Quote:

Originally Posted by druuna (Post 4872705)
Assuming that the infile provided is correct (use [code]..[/code] tages to preserve spacing etc), have a look at this:
Code:

awk '/^set command/ { print > "FILEA" } !/^set command/ { print > "FILEB"} ' infile


Thanks for your reply ....
But still ..
I request for the query not filter by the starting word ...
It has to give the lines present from "this word" to "this word" ..

druuna 01-25-2013 07:01 AM

Quote:

Originally Posted by Boopathiraj (Post 4877269)
Thanks for your reply ....
But still ..
I request for the query not filter by the starting word ...
It has to give the lines present from "this word" to "this word" ..

In that case:
- Provide a valid example of the input file,
- Provide an example of the wanted output file(s) based on the example input file.

Boopathiraj 01-31-2013 07:44 AM

Quote:

Originally Posted by druuna (Post 4877278)
In that case:
- Provide a valid example of the input file,
- Provide an example of the wanted output file(s) based on the example input file.


Hi Thanks for continues support...

Below is the file ...
----------------------------------------
Code:

.
.
.
.
.
.
applications {
   
        application TCS-ULTIMATIX-PORTS
        {
      asdfadf
    }
   
       
        application TCS-GHD-PORTS
        {
      sdfsdfsdf
        }
   
        application TCS-IM-PORTS {
        sdfsdfsdf
    }
 
        application-set TIVOLI-TPM-PORTS {
        application TCS-GHD-PORTS;
        application TCS-ULTIMATIX-PORTS;
    }
    application-set ONSCR9PRT {
        application TCS-GHD-PORTS;
        application TCS-ULTIMATIX-PORTS;
    }

------------------------------------------------
My requirement is , need to cut the file from the word "applications" to the end of the file..

(or )

Need to cut the file from the word "applications" to the word application-set.

trey85stang 01-31-2013 03:59 PM

use code tags... and give an actual input and output expectation. You might want to also exlain what you have tried so far.


All times are GMT -5. The time now is 01:43 PM.