SED/AWK command

Hi All,

I have a file which has following lines :

- Deploy XXX application [2] <server-address>
- info [4] <server-address>
- Deploy XXX application [2] <server-address>
- info [4] <server-address>
- Deploy XXX application [2] <server-address>
- info [4] <server-address>

I want output like this way in flat file

Deploy XXX application
info
Deploy XXX application
info

There may be any kind of string instead of Deploy/info.
Not able to make proper SED/AWK commands, please help.

Thanks in advance.
Regards,
Bhaskar

Maybe this?

awk '/Deploy/{print $2,$3,$4;getline;print $2}' file

Hi,

The file may appear also as. This is a log of one application.

- XXXXXXX [2] <server-address>
- YYYYYY [4] <server-address>
- ZZZZZZZ[2] <server-address>
- AAAAA [4] <server-address>
- BBBBBBB [2] <server-address>
- ZZZZZ [4] <server-address>

I need to filter this file to an another output file which will contain like this

- XXXXXXX 
- YYYYYY 
- ZZZZZZZ
- AAAAA 
- BBBBBBB 
- ZZZZZ  

That is I am just filtering out the strings from the log lines.

HTH

Regards,
Bhaskar

Try:

awk NF-=2 infile
sed 's/ \[.*//' infile

Both are working.
Thanks a lot!!

Cheers!
Bhaskar

Nice one :wink:

Yeah very Cool...Even I tried lot of tricks this were missed..Thank u guys for putting your efforts.

Good Day.

Cheers!!

Courtesy rdcwayx :wink: /t/how-to-get-part-of-file/278257/1

nawk -F' \\[' '{print$1}' infile