Method for obtaining the process ID by shell:
I know there are three things I have learned and practiced:
- PS-A | grep "cmdname" | awk '{print $1 }'
- Pidof "parameter name"
- Pgrep "cmdname"
The three running results in bash and busybox ash are slightly different,
The first method is identical, but the performance is not good because the number of invocation commands is large.
The second type: pidof can only obtain the process number that matches the program's file name. In ash, for example, pidof "usr/bin/telnetd" and pidof "telnetd" have different results, the previous result is empty, but the two are the same in bash.
Third: pgrep has the same effect as 1, because it is a single command, it is much better than the first one.
Therefore, nanorc is improved to pgrep.
Method for obtaining the process ID by shell: pidof | pgrep | PS-A + grep + awk