Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
In mylog.log has
File Description Status
PID1 Testing1 Active
PID3 Testing2 NotActive
PID7 Testing3 NotActive
PID8 Testing4 Active
PID9 Testing5 NotActive
How do I write a script to extract information from mylog.log, let says just Description and Status?I want to write a script that gives me the flexibility to choose which column to present to me. If I typed D and S, I will get the description column and Status column
Description Status
Testing1 Active
Testing2 NotActive
Testing3 NotActive
Testing4 Active
Testing5 NotActive
=================Second Part================With the same log, how would I reconstruct the data into more meaningful script? Let say, If PID exist, I want it to tells me in a more meaningful way. If I do grep PID1, I would be getting
PID1 Testing1 ActiveI want the to return to me as the following.
PID1 is at Active Status for Testing1.

Look at cut for the first portion and
ps -ef | grep $pid for the second. Piping the ps command through cut or awk will probably help you.

![]() |
![]() |
![]() |

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