FizzBuzz written in sed.
$ echo [number] | ./fizzbuzz.sed
Or without execute permission:
$ echo [number] | /pass/to/sed -f ./fizzbuzz.sed
If your computer doesn't have echo, you can also do the following:
$ ./fizzbuzz.sed [number]
$ ./fizzbuzz_stand_alone
- Don't change the script file name
- Run in the same directory as the file
If you want to change the number of times, change the number of 4th line. Don't change other than numbers.
$ ./oneliner.sed
You can run this program anywhere and you can change the file name to any one.
If you want to change the number of times, change 100
in the program (one place) to positive integer does not start with 0 what you want
. If your input is illegal, this program will quit with print Error
.
The number of times of this program has limit because of a shebang limit. The maximam number you can use is 999999999
(I check it with only a shell I use).
I could not add the future which print detailed error message because of a shebang limit.
- TODO
- Minimal one-liner version
$ ./twoliner.sed
One-liner version has a limit because of a shebang limit. Two-liner version will solve this issue. Other description is same as the one-liner version:
You can run this program anywhere and you can change the file name to any one.
If you want to change the number of times, change 100
in 2nd line to positive integer does not start with 0 what you want
.
- sed
This program works with BSD sed, GNU sed, and POSIX sed.
This program works with BSD sed too, and it works fine now. But I recommend to use GNU sed for GNU extensions.
If you use macOS with Homebrew, you can install GNU sed as follows:
$ brew install gsed
I think this program dose not work with sed too old version because of limit of pattren space. But I cannot check it because I don't have sed old version.
- TODO
- Version control tool for sed
Run following commands:
$ git clone https://github.com/minamotorin/FizzBuzz-sed.git $ cd FizzBuzz-sed $ chmod +x fizzbuzz.sed FizzBuzz_stand_alone oneliner.sed twoliner.sed
And run FizzBuzz program. Have fun!
- TODO
- Test script
- GNU sed online manual
- Usage of sed
- Solving Arithmetic Golf Problem with Sed
- The idea of successor function
- Hello world in every computer language
- Stand-alone version
- FizzBuzz solutions in any language you want!
- Needs to be rewritten every time the value is changed
- FizzBuzz in every programming language
- Depends on shell
- sedbuzz
- Depends on seq but good at check divisibility
- fizzbuzz.sed
- Very good
If you have any requests, bug reports, please use GitHub issues.
This program is under the Do What the Fuck You Want to Public License. Repository is here.