963 shaares
35 results
tagged
bash
a handful of CLI tools that makes my life easier. Here are some of them.
How do you get the length of a string stored in a variable and assign that to another variable (With emphasis on UTF-8)
I'm trying to do something common enough: Parse user input in a shell script. If the user provided a valid integer, the script does one thing, and if not valid, it does something else. Trouble is, I haven't found an easy (and reasonably elegant) way of doing this - I don't want to have to pick it apart char by char.
How to write a bash script that takes optional input arguments?
How can I pipe some input using echo, into program that requires user typing something two times?
Sous Linux, quand nous travaillons en ligne de commande, il est souvent bien pratique d'avoir la possibilité d'exécuter plusieurs commandes en une seule ligne.
Dateutils are a bunch of tools that revolve around fiddling with dates and times in the command line with a strong focus on use cases that arise when dealing with large amounts of financial data.
The GNU date command in full of goodies but not when it comes to calculate a date or time difference. Here is what I came up with after looking to more than one solution. Code should be self explaining.
We aim to collect practical, well-explained bash one-liners, and promote best practices in shell scripting.
This guide aims to aid people interested in learning to work with BASH. It aspires to teach good practice techniques for using BASH, and writing simple scripts.
This guide is targeted at beginning users. It assumes no advanced knowledge -- just the ability to login to a Unix-like system and open a command-line (terminal) interface. It will help if you know how to use a text editor; we will not be covering editors, nor do we endorse any particular editor choice. Familiarity with the fundamental Unix tool set, or with other programming languages or programming concepts, is not required, but those who have such knowledge may understand some of the examples more quickly.
This guide is targeted at beginning users. It assumes no advanced knowledge -- just the ability to login to a Unix-like system and open a command-line (terminal) interface. It will help if you know how to use a text editor; we will not be covering editors, nor do we endorse any particular editor choice. Familiarity with the fundamental Unix tool set, or with other programming languages or programming concepts, is not required, but those who have such knowledge may understand some of the examples more quickly.
BASH offers three different kinds of pattern matching. Pattern matching serves two roles in the shell: selecting filenames within a directory, or determining whether a string conforms to a desired format. On the command line you will mostly use globs. These are a fairly straight-forward form of patterns that can easily be used to match a range of files, or to check variables against simple rules. The second type of pattern matching involves extended globs, which allow more complicated expressions than regular globs.
How can I use a logical AND/OR/NOT in a shell pattern (glob)?
rm -- *.bak *.old
rm -- *.{bak,old}
rm -- *.bak *.old
rm -- *.{bak,old}
pattern matching (also for bash)
This script backs up all databases on the server it’s running on. Usually ran as a cron job.