Skip to content

minamotorin/fizzbuzz-sed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Abstract

FizzBuzz written in sed.

Usage

$ 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]

Stand-alone version

$ ./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.

One-liner version

$ ./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.

A limit of shebang

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

Two-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.

Dependencies

  • 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

NOTE

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

Installation

Dependencies

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

Reference

I used as a reference

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

Similar project

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

Issue

If you have any requests, bug reports, please use GitHub issues.

License

This program is under the Do What the Fuck You Want to Public License. Repository is here.

About

FizzBuzz written in sed

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published