2

after doing the command in the terminal: forever list

i get the following output:

info:   Forever processes running
data:       uid  command script           forever pid logfile                              uptime        
data:   [0] 0ClV node    enfomo-server.js 376     377 /Users/USERNAME/.forever/0ClV.log 0:0:37:26.987 

i need to use grep or some alternative to give as output the following string only:

/Users/USERNAME/.forever/0ClV.log

what is the proper command?

0

2 Answers 2

3

You can do this with grep using the -o flag which only prints the matching part:

forever list | grep -o '\/Users.*log'
Sign up to request clarification or add additional context in comments.

3 Comments

Note: this approach relies on the content, rather than the position. This may be ideal, or it may be limited, depending on the data, which is not characterized.
Thank you Paul for pointing this out, I interpreted the question as being dependent on content.
ahh. was a character or two off in my regex.
2

First you might want to isolate only the lines you want with grep, then awk would work:

grep node file | awk '{print $7}'

or cut:

grep node file | cut -d\  -f7

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.