Earlier quoted context omitted.
Which makes it a valid reference for bash.
That's like saying a well-written C program is a good reference for C++. In any case, writing POSIX-only shell scripts is much harder than writing Bash scripts, which can often be much faster (e.g., one can use {1..10}, which doesn't need an external call, instead of `seq 1 10` to iterate through a list of numbers). For POSIX-only shell scripts, the ones used in Git [1] are some of the best-written I've seen. [1]: ht…
Fast Markov chains in ~20 lines of sh, grep, cut and Awk
31–40 of 42 posts
Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#32Earlier quoted context omitted.
bash, grep, awk, are all gnu tools
grep is from AT&T Unix version 6. awk is from AT&T Unix version 7. Bash is from Gnu but the script is actually plain old Bourne Shell from AT&T Unix version 7.
If you are on linux, you are using GNU grep, not unix grep.
Others have addressed bash... so wrong on all counts.
Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#33Earlier quoted context omitted.
`shuf` is not POSIX, so that would make this BASH.
It wouldn't necessarily make it Bash. That would mean using actual Bash features. It's still non-portable sh, because it relies on an extra program being available, but it isn't relying on Bash itself - none of expansions or so on. This is what makes it Bash: file="${1:-~/.mrkdb}" Not shuf.
Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#34Earlier quoted context omitted.
grep is from AT&T Unix version 6. awk is from AT&T Unix version 7. Bash is from Gnu but the script is actually plain old Bourne Shell from AT&T Unix version 7.
"AWK was significantly revised and expanded in 1985–88, resulting in the GNU AWK implementation written by Paul Rubin, Jay Fenlason, and Richard Stallman, released in 1988.[8] GNU AWK may be the most widely deployed version" AWK wikipedia entry If you are on linux, you are using GNU grep, not unix grep. Others have addressed bash... so wrong on all counts.
Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#35Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#36Earlier quoted context omitted.
grep is from AT&T Unix version 6. awk is from AT&T Unix version 7. Bash is from Gnu but the script is actually plain old Bourne Shell from AT&T Unix version 7.
"AWK was significantly revised and expanded in 1985–88, resulting in the GNU AWK implementation written by Paul Rubin, Jay Fenlason, and Richard Stallman, released in 1988.[8] GNU AWK may be the most widely deployed version" AWK wikipedia entry If you are on linux, you are using GNU grep, not unix grep. Others have addressed bash... so wrong on all counts.
Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#37Earlier quoted context omitted.
What makes this gnuland?
bash, grep, awk, are all gnu tools
Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#38Earlier quoted context omitted.
The question of how many words are used is discussed here: https://en.wikipedia.org/wiki/N-gram#n-gram_models See also https://en.wikipedia.org/wiki/Google_Ngram_Viewer which recently popularized the term n-gram.
> which recently popularized the term n-gram. Eh? It's well known in Info Retrieval; it goes back at least to Salton's IR group at Cornell in the 1970's.
Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#39Earlier quoted context omitted.
"AWK was significantly revised and expanded in 1985–88, resulting in the GNU AWK implementation written by Paul Rubin, Jay Fenlason, and Richard Stallman, released in 1988.[8] GNU AWK may be the most widely deployed version" AWK wikipedia entry If you are on linux, you are using GNU grep, not unix grep. Others have addressed bash... so wrong on all counts.
None of it is specific to GNU and you can easily do it without any GNU tools on MacOS, if you've heard about that niche operating system.
Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#40This is awesome because it is a real shell script that does something interesting AND it's well documented. I'm bookmarking this as a bash script reference.
Not being pedantic, but OP's script isn't Bash, it's POSIX sh. POSIX sh can be executed in Bash, but there are several differences. The only non-POSIX command I can spot in that script is shuf.