Check if a hay[stack] contains a [needle] in the command line with some options.
Nothing new here, just a different way to do it.
I just like to build tools the way I want them to work. If this works well for you then that's great and I hope you get god use of it.
This is a command line tool that should work in any shell/terminal/console/tty in several operating systems.
This is a portable application with no dependencies, but the Linux version has a deb
package installer that provides simple Bash Completion
and some icons for hicolor
. If it is not installed it should be placed in your PATH
in your respective environment. if you don't put in a PATH
then you will have to run it directly, of course.
Your PATH
's can be found in your respective variables per your operating system (of course, you might've added your own directories to the PATH
:
echo $PATH
# or
printf '%s\n' $PATH
PowerShell
Write-Host $Env:PATH
CMD
echo %PATH%
This is a very simple program that accepts a -h, --help
switch and strings of of characters and is used the same way regardless of which environment you're in.
Windows Examples
PowerShell:
# Not in path
& 'C:\Path\To\contains.exe' --needle 'World' --haystack 'Hello World' &&
>> Write-Host True ||
>> Write-Host False
True
# In path
contains -n "World" -s "Hello, You" &&
>> Write-Host True ||
>> Write-Host False
False
# Get character position
contains -n 'b' -s 'abc' --position
2
Everything Else Examples
# Not in path
$ /path/to/contains -n PM -s "$(date)" &&
> printf '%s\n' "Good afternoon." ||
> printf '%s\n' "Good morning."
Good afternoon.
# In path
contains -n AM -s "$(date)" &&
> printf '%s\n' "Good afternoon." ||
> printf '%s\n' "Good morning."
Good morning.
Help Screen
contains --help
'contains' - Check if a hay[stack] contains a
[needle]. This can either return an EXIT_CODE
(0 or 1) on found or not or it can PRINT a
positional start integer with the 'position'
switch.
USAGE:
contains <SWITCH [PARAMETER]>...
if contains -n needle -s stack; then ... fi
contains -n needle -s stack && echo found...
contains -n needle -s stack --position
SWITCH:
-h, --help This help message.
-n, --needle What to find. [needle]
-s, --haystack Where to look. [stack]
-i, --insensitive Test is case insensitive.
-p, --position PRINT the position of the
starting character if
found. This changes the
behavior of the program
printing output rather
than returning an exit
code.
PARAMETER:
needle - String of characters to find.
stack - String of characters to look in.
This project is written in C++
.
Description | Status |
---|---|
Project Release Date | |
Total downloads for this project | |
Complete repository size | |
Commits in last month | |
Commits in last year |
Latest Version Status
Description | Status | Number of Downloads |
---|---|---|
Latest Release version | ||
Latest Tag version, possible Pre-Release's |
All current compiled files and the source of this project can be found at this repository in the Releases
section under Stable Release
and can be found in 32 (X86) and 64 (X64) bit format for Windows and 64 bit otherwise.
You may want to rename any of the provided executables to contains
(or contains.exe
).
This is the recommended method of download.
You can, of course, build, fork, and/or download the source of this project as per the LICENSE of this project. If you want me to create a build for a different architecture and don't want to do it yourself then just let me know what you need and I'll look into it.
These MD5 values are evaluated immediately after the build.
Windows X86 MD5
Windows X64 MD5
Linux MD5
Debian MD5
Android MD5
A simple little logo I created in Glimpse (new verion of GIMP).
This is in the Windows executables and is installed with the hicolor theme with the Linux .deb installer.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
...