sttr command line text manipulation tool

16 lug 2024 2 min di lettura
sttr command line text manipulation tool
Indice dei contenuti

Introduction

sttr is an open-source tool developed in Golang, designed to edit and transform texts directly from the command line. This tool allows you to perform transformation operations such as hashing, string manipulation and much more. It is especially useful for *nix developers and users who need quick changes to strings or files via CLI or text user interface (TUI). Ideal for scripting, data processing and automation tasks, sttr simplifies text management.

Installing sttr on Linux or Unix

macOS

To install sttr on macOS, you need to enable Homebrew and use the following commands:

brew tap abhimanyu003/sttr
brew install sttr

If you have macports installed, use the command:

sudo port install sttr

ArchLinux

For Arch Linux users, use the yay command:

yay -S sttr-bin

Debian/Ubuntu and other snap distros

If you have enabled snap packages, run the following command:

sudo snap install sttr

Windows

On Windows, use curl as follows:

curl.exe https://webi.ms/sttr | powershell

Other Linux and Unix systems

You can install sttr by downloading the install.sh script from the official repository. It is recommended to install it in the./bin directory in your home directory:

wget https://raw.githubusercontent.com/abhimanyu003/sttr/main/install.sh
vim install.sh
bash install.sh

Using sttr

After installation, sttr is ready to be used. The basic syntax is:

sttr comando "testo"
echo -n "testo" | sttr comando

For example, to convert text to lowercase or uppercase:

echo "QUESTO è UN TEST" | sttr lower
echo "QUESTO è UN TEST" | sttr upper

To convert text to CamelCase or kebab-case:

sttr camel "esempio_testo"
sttr kebab "esempio_testo"

To get the SHA512 or SHA256 checksum of your text:

sttr sha512 "esempio di testo"
sttr sha256 "esempio di testo"

You can start sttr in TUI mode with the command:

sttr

Enter your text and press [Enter] twice to see the menu options.

Get help

For help with sttr commands, use the -h or --help options:

sttr -h
sttr --help
sttr sha512 -h

You can also use the grep command to search for specific options:

sttr -h | grep lower
sttr -h | grep -E 'lower|upper'

Format conversions

sttr allows you to convert YAML texts to JSON and vice versa. Here is an example to convert a YAML file to JSON:

dig +yaml +short A esempiosito.com > output.yaml
cat output.yaml
sttr yaml-json output.yaml
sttr yaml-json output.yaml > output.json
cat output.json

Data extraction

You can extract IPv4 and IPv6 addresses from your text:

sttr extract-ip input.txt

And also URL:

sttr extract-urls input.txt

Conclusion

sttr is a versatile and powerful tool for those who frequently work with command line texts. From encoding and decoding, to filtering and extracting URLs, IPs and email addresses, sttr offers a wide range of features. It is an ideal solution for Linux/Unix developers and users looking for efficiency in text manipulation. For a full list of features and additional usage details, visit the project's GitHub repository page.

Support us with a

Successivamente, completa il checkout per l'accesso completo a Noviello.it.
Bentornato! Accesso eseguito correttamente.
Ti sei abbonato con successo a Noviello.it.
Successo! Il tuo account è completamente attivato, ora hai accesso a tutti i contenuti.
Operazione riuscita. Le tue informazioni di fatturazione sono state aggiornate.
La tua fatturazione non è stata aggiornata.