nixCraft Linux / UNIX Newsletter

Link to [RSS/Feed] nixCraft: Linux Tips, Hacks, Tutorials, And Ideas In Blog Format

How to repeat a character ā€˜nā€™ times in Bash

Posted: 04 Jun 2021 03:43 AM PDT

See all UNIX related articles/faq

Let us say you want to repeat a character such as '-' OR '=' multiple times while writing bash script. Please note that I needed a quick script to work on Linux, macOS, and FreeBSD server to repeat a string/character n times. One simple way to to repeat a string or character n times is simple use the echo command/printf command as follows:

echo '------------------------------------' printf '%s\n' '------------------------------------'

The post How to repeat a character ā€˜nā€™ times in Bash appeared first on nixCraft.

Shell script too see Time-To-Live (TTL) for a DNS record

Posted: 03 Jun 2021 02:14 PM PDT

Say you want to see the Time-To-Live (TTL) value for a given DNS record for A, AAAA, and MX. Here is a sample shell script that works on Linux, Unix, and macOS. You must have the bash and dig command installed.