0
 [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 Apr 3 '17 at 12:29
1
awk '$2 == "INACTIVE"{print $1}' input.txt
0

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 Apr 4 '17 at 4:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.