spencertipping / fsh Goto Github PK
View Code? Open in Web Editor NEWFunctional shell scripts
Home Page: http://spencertipping.com/fsh
Functional shell scripts
Home Page: http://spencertipping.com/fsh
Functional shell scripts | Spencer Tipping Licensed under the terms of the MIT source code license These scripts provide a functional shell environment. This gives you the ability to use constructs similar to those in functional programming languages, but on the shell level. This project is uninspired at present and needs ideas. The 'each' command takes each line of input and maps it to _ in the command you give it. Iteration terminates if the command returns nonzero status. ls | each echo _ # The same as ls ls | each cat _ # Concatenates everything in this directory ls | each 'ln -s _ _.txt' # Symlinks each file as file.txt ls | each 'ln -s _ $(md5sum _ | awk "{print \$1}")' # Symlinks each file as the MD5 of its contents ls | each 'test -f _ && echo _ || :' # Only print regular files ls | each 'echo _ $(($(wc -c < _) / $(wc -l < _)))' # Display characters per line for each file You can also use 'each' to emulate other concepts: ls | each cat _ # This is really flat-mapping across files and lines of files ls | each 'test -d _ && ls _ || echo _' # Flat-map one level across directories ls | each 'test -d _ && ls _ | cat || echo _' # Ditto, but this one gets proper output from ls And you can use it with things besides ls: ps -e | grep '\bdhclient\b' | cut -d' ' -f1 | each kill -9 _ ifconfig | grep '^\w' | sed 's/\s.*//' | each ifconfig _ down 'peach' is like 'each', but runs its jobs in parallel: seq 1 10 | peach 'sleep 1 && echo _' # Returns after one second The 'y' command repeats something until the command returns nonzero status. From a functional point of view, it's a sort of fixed point on system state. y ps -el | grep perl # Print all Perl processes continuously (CPU hog) y 'sleep 1 && ps -el' | grep perl # Print all Perl processes each second (not a CPU hog) y 'sleep 1 && ps -el | grep perl | wc -l' # Print the number of Perl processes each second y 'test -f foo || touch foo' # Make sure the file 'foo' never goes away (CPU hog) y y # No clue, but seems dangerous 'uncat' does the opposite of cat: cat foo | command # Prints the contents of foo into the command command | uncat bar # Writes the output of command into bar command | uncat # Writes the output of command into a tempfile and prints the tempfile In general, uncat has the invariant that 'cat $(cmd | uncat)' is equivalent to 'cmd', modulo buffering. 'repeat' repeats something a fixed number of times: repeat 10 echo hi # Says 'hi' ten times This is useful for things like benchmarking.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.