android - Finding substring at the end of line in shell -


i new shell scripting.

when write adb shell ps | grep "org.mozilla.fennec"

u0_a52    908   57    557664 144820 ffffffff b6f755cc s org.mozilla.fennec 

and

u0_a52    1083  57    243108 23824 ffffffff b6f755cc s org.mozilla.fennec.updateservice 

the problem need first line. tried adb shell ps | grep "org.mozilla.fennec$" surprisingly shows nothing.

i need second field of first line. how can using grep? appreciated. thanks.

to print 2nd field can use awk:

adb shell ps | awk -v rs='\r' '$nf == "org.mozilla.fennec"{print $2}' 

to print whole line:

adb shell ps | awk -v rs='\r' '$nf == "org.mozilla.fennec"' 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -