A tool that reads numbers from stdin and outputs them to stdout only if they are within a specific range
cat data.txt | inrange $LOWER $UPPER > data_clean.txt
inrange
reads data line by line from stdin.
It expects one number per line.
Invalid lines will be dropped (a warning will be printed to stderr).
For each valid line, the tool checks if the value is in a specific range: value ≥ lower-limit ∧ value ≤ upper-limit.
If the value is in the defined range, it gets print to stdout.
The range is defined by the command line arguments. It is recommend that the first argument is the lower limit and the second argument the upper limit. The tool actually checks and swaps the limit if necessary.
The data type of the values get determined when the tool gets built. See the Build Options section of this readme. By default, the tool expects integers.
To compile inrange clang++
is required.
You may change the compiler to g++
in the build script.
# 1. DOWNLOAD
git clone https://github.com/rstemmer/inrange.git
cd inrange
# OPTIONAL: You can edit build.sh for a different data types (see next chapter, default is "long long")
# OPTIONAL: You can edit install.sh for a different installation directory (default is "/usr/local/bin")
# 2. BUILD
./build.sh
# 3. INSTALL
sudo ./install.sh
Edit the build.sh
script to change the data type the tool works with.
Default is long long
- On a 64bit x86 based Linux machine, this is a 64bit signed integer.
Valid types are: int
, long
, long long
, unsigned long
, unsigned long long
, float
, double
and long double
For details about the data types see the C++ reference.