[Time: 2017/04/03 07:27:30.048] [comp_ctrl]: Connecting to server......
    [Time: 2017/04/03 07:27:30.739] [comp_ctrl]: Connected to server.
    [Time: 2017/04/03 07:27:30.739] [comp_ctrl]: Execute list collabrations operation......
    The collaboration name:                                        The status:
    BooleanExpression1234                                          ACTIVE
    BooleanExpression1235`                                         INACTIVE
    There are total 2 collabrations listed.

For the above input,I want a shell program to output like below removing all other characters(finally output i require is to get the first column values which are only in INACTIVE status in second column) File used to input will have multiple records.

BooleanExpression1234                                          ACTIVE
BooleanExpression1235                                          INACTIVE

I tried to get remove the unwanted contents through awk but not really working.

  • 3
    What did you try with awk? How did it fail? If you only want the INACTIVE lines, why are you showing ACTIVE in your output? Are you just looking for grep INACTIVE file? Please edit your question and clarify. And also mention your operating system.
    – terdon
    Commented Apr 3, 2017 at 12:29

2 Answers 2

awk '$2 == "INACTIVE"{print $1}' input.txt

For getting both ACTIVE and INACTIVE lines in the output:

grep ACTIVE sample.txt|awk -F " " '{print $1}'

For getting only INACTIVE line in the output:

grep INACTIVE sample.txt|awk -F " " '{print $1}'

Where sample.txt is the file containing the input text.

  • Glad to know :)
    – Tinu
    Commented Apr 4, 2017 at 4:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .