Get the character length of a string from the command line.
Nothing new or fancy here; testing a string of text's length is something we programmers do all the time, of course, but I wanted something in the command line without the need to pipe to wc
or something similar. This code is very simple; you may or may not have seen something like this before, but I assure you this is my code.
I need the length of strings often.
I like small tools that do simple things and that can reduce the need to pipe or redirect. I also like to utilities that work cross-platform. I also just like to program everything; redundant or not...
This is a command line tool that should work in any shell/terminal/console/tty in most 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
Write-Host $Env:PATH
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\strlen.exe' "this is a string"
16
# In path
strlen " this is a another string "
25
CMD:
REM Not in path
'C:\Path\To\strlen.exe' "this is a string"
16
REM In path
strlen " this is a another string "
25
Everything Else Examples
# Not in path
/path/to/strlen "this is a string"
16
# In path
strlen " this is a another string "
25
Help Screen
strlen --help
'StrLen' - Get the character length of a string
in the command line.
USAGE:
strlen [SWITCH] <STRING>
SWITCH:
-h, --help This help message.
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 |
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 strlen
(or strlen.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
Miscellaneous information about the binary executables built and released by the workflows here.
Linux Information
The Linux build (strlen
) was built here with this makefile using make
and g++-9
.
It has been also built and tested on:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
Android Information
The Android build (strlen.arm
) was built here with this makefile using make
and arm-linux-gnueabi-g++
.
It has been built for armv8-a
and tested on a Samsung S9, Android V10
.
If you want a different version of architecture for Android and don't want to fork and do it yourself then let me know what you need and I'll look into adding the build.
Windows Information
The Windows builds (strlen-x86.exe, strlen-x64.exe
) were built here with this Visual Studio solution using msbuild
.
It has been built for both 32bit
and 64bit
versions of Windows 10 tested on Windows 10
.
Windows Linux and Android Demos
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.
...