It is a Python implementation of this idea: OS objects like files and processes are represented in Python. You construct pipelines as in UNIX, but passing Python objects instead of strings. E.g. to find the pids of /bin/bash commands:
osh ps ^ select 'p: p.commandline.startswith("/bin/bash")' ^ f 'p: p.pid' $
- osh: Runs the tool, interpreting the rest of the line as an osh command.- ^: Piping syntax.
- ps: Generate a stream of process objects, (the currently running processes).
- select: Select those processes, p, whose commandline starts with /bin/bash.
- f: Apply the function to the input stream and write function output to the output stream, (so, basically "map"). The function computes the pid of an input process.
- $ Print each item received in the input stream.
Osh also does database access (query results -> python tuples) and remote access. E.g., to get a process listing of (pid, commandline) on every node in a cluster:
osh @clustername [ ps ^ f 'p: (p.pid, p.commandline)' ] $ pgrep -f /bin/bash osh timer 1 ^ \
f 't: (t, processes())' ^ \
expand 1 ^
f 't, p: (p.pid, int(t), p.commandline)' ^
sql "insert into process values(%s, %s, %s)"
- timer 1: Generate a timestamp every second.- f 't: (t, processes())': Take the timestamp as input and generate a timestamp and sequence of Process objects.
- expand 1: Expand the sequence of Processes, so that there is one per output tuple, e.g. (123, (p1, p2)) -> (123, p1), (123, p2).
- f 't, p: (p.pid, int(t), p.commandline)': Take the timestamp and Process as input, and generate (pid, timestamp as int, command line) as output.
- sql "insert into process values(%s, %s, %s)": Take the triples from the previous command and dump them into a table in a database.
1..500 | ?{ !(Test-Path ('{0:0000}_A.csv' -f $_)) }
Explanation:1..500 generates a sequence of numbers 1 through 500
| pipes the numbers
?{ … } is a filter that is evaluated for each item (number)
! negates the following expression
Test-Path tests that a file exists
-f formats the string left of -f with the parameters (zero-based to the right of -f
'{0:0000}_A.csv' is a pattern which formats parameter 0 as 4 digits, zero-padded.
EDIT: Explanation
for f in {0001..0500}_A.csv; do test -e $f || echo $f; doneBut dont say powershell is not practical for simple things. Its very practical for simple and complex things. And I am productive with it.
If you do a lot of work with Exchange though, you'll probably end up using PowerShell much more, because the web UI for it is not so great.
No matter what you think of the specific implementation, a lot of PowerShell's ideas are good ideas. Unfortunately UNIX culture is such that they'll probably never implement any of them.
ssh, docker, ansible, kubernetes, grafana, prometheus, etc... All coming from Linux/unix. This statement is clueless. Most of the cloud is not running microsoft, and for a good reason.
To automate, we have python, which has a much better syntax. It's pointless to use powershell.
And it takes a microsoft head, without knowledge of programming language's history to say that powershell's ideas actually come from powershell. Method chaining/fluent interface with a pipe instead of a dot does not look that new.
Also, some attempts have been to implement posh clones on unix. Being redundant with either perl/python or bash/zsh, none succeeded.
I would like to see more work done in the realm of object shells (and have some ideas myself), especially around designs that meld in more the UNIXy way of having independent communicating processes. But it is a difficult problem domain, and many approaches would involve rewriting lot of the base system we take for granted that is just huge amount of work.
PowerShell had the benefit of having stuff like WMI, COM, the whole .NET, and of course all the resources, funding and marketing from MS. Even then it has seemed to have been an uphill struggle, despite there being far more a need for PS in the Windows world.