[SOLVED] How to read keyboard input shift M in script when run top in linux

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below. ** If you are logged in, most ads will not be displayed. **

You can use ~/.toprc to make top always run with certain settings (like pressing M). When top is running, press M, then press W and it will save your configuration to ~/.toprc. Next time you run top, it should have those settings you've said from the previous top session.

Yes, I have tried generation ~/.toprc this method which runs good in my linux terminal. But it maybe some drawback which can be used only under my linux environment.
if somebody also want to descend sort memory, he must use the same way to get a ~/.toprc file.
this method with poor replicability and portability!