as i wrote... "(the above stuff is just for demo purposes... it's not the recommended way to do it. It's just to show the functionality..)"..... ie it's not the optimal way.. it's just for demo-purposes to show how pipes and such are much more powerful to manage output from a command...
The good thing about this is that i can write a minimal shell-script that does something and parse the output with whatever command i might want.. Or even pipe the output from a command to a shell-script that does something more advanced with the output...
Please learn how to read...
I didn't say "export to some random text file", I said, "comma separated values" (CSV) file -- something I can double-click and open in Excel without problems.
Ever heard about import data in excel?... you can use comma, tab, spaces or whatever you would like to import data... it does not have to be a cvs file... But if you would like.. You can even right-click on the file and select open with excel and it will go into import-mode... So... the problem is?
But sure.. i'll bite...
ps h -o "`hostname`,%p,%y,%x,%c"
and the "cryptic" variables here are defined in the man-page..
CODE NORMAL HEADER
%C pcpu %CPU
%G group GROUP
%P ppid PPID
%U user USER
%a args COMMAND
%c comm COMMAND
%g rgroup RGROUP
%n nice NI
%p pid PID
%r pgid PGID
%t etime ELAPSED
%u ruser RUSER
%x time TIME
%y tty TTY
%z vsz VSZ
There's no need for pages of cryptic options for such a basic command as "ps". Take a look at the list of options for Get-Process [microsoft.com]. Not counting common parameters, it has a grand total of just six! In comparison, ps has over 50, and the list depends on the platform.
Cryptic???? Tell me one option that is cryptic??.. and... a total of 6 things you can output for a process... that is limiting the usefulness of the command...
And about that the list depends on the platform... Of course, it has too... They are different platform with different types of information for the processes... The POSIX standard defines a number of "must have" that should be platform independent... And options are not, usually, removed or renamed between versions, like Microsoft does between each version...
Notice how "ps" has like... a bazillion options? What the fuck is "-ef"? I had to look it up. It's "show every process" in "full format".
-f does full-format listing. This option can be combined with many other UNIX-style
options to add additional columns. It also causes the command arguments to be
printed. When used with -L, the NLWP (number of threads) and LWP (thread ID)
columns will be added. See the c option, the format keyword args, and the format
keyword comm.
If you use it you know what it means... It's the same in windows... I would say having to start with $_. is more cryptic...
Also something that is very powerful in a bash shell is the possibility to use regexps for basically all commands.... like: (Yes i know i can specify the process, but to not confuse the windows-user you are i'm clarifying that i just use the ps output here to display the regexp functionality.)
$ ps |grep "bash$"
4629 pts/0 00:00:00 bash
$ ls
10000
10001
12001
13001
14001
15001
16001
$ ls 1[034]*1
10001
13001
14001
Everything tab-completes in PowerShell, even the parameter names.
Try doing that if you have a special character in the folder-name you are in... Tab-completion for parameters is possible in Linux too..
http://stackoverflow.com/questions/776071/surprise-the-shell-suggests-command-line-switches
Of course not for all commands because that would be a hell of a job to implement... But you have full freedom to extend, as you must do in windows for extra commands, the completion with whatever support you might like...
It certainly doesn't have the same output format as any other command. Notice how the exact same option to "service" is not "-ef", but "--status-all". Does "service" have a "sort" option? Nope
Well, you cannot have the same output for services... Because a service can consist of several processes.... A service can even just be something that should be executed once without a running process... Like having ntpdate executed once during boot and having other services depend on it...
So go do your homework again...