Awk '{print $14}'

Hi:
In the command used: logPath=$(ps -ef | grep mongo | grep 30000 | awk ‘{print $14}’)
awk prints the 14th field of every line in mongod.log or mongos.log, but what’s in the 14th field if I may ask??
Thanks,
RT

As the variable name indicates it is storing logPath
What do you see in your ps -ef|grep mongo|grep 3000 output

1 Like

Hi.
There are only 16 fields (8 key-value pairs) in the output (see below).
How is the logpath value located in the 14th field?
Thanks.

vagrant@m312:~$ ps -ef | grep mongo | grep 30000

vagrant 2132 1 13 18:02 ? 00:01:05 mongod --replSet m312RS --dbpath /home/vagrant/data/m312RS/rs1/db --logpath /home/vagrant/data/m312RS/rs1/mongod.log --port 30000 --fork --wiredTigerCacheSizeGB 0.3

How you are getting 16 fields?
Not clear what you meant by value pair.We are not checking any json doc
Start counting from vagrant.The 14th field is logpath

2 Likes

YES, it is the 14th!!!
Thank you.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.