Skip to content

Instantly share code, notes, and snippets.

@h8rt3rmin8r
Created January 27, 2019 13:16
Show Gist options
  • Save h8rt3rmin8r/f0f1f3fbbe372820fb103d1541d3672b to your computer and use it in GitHub Desktop.
Save h8rt3rmin8r/f0f1f3fbbe372820fb103d1541d3672b to your computer and use it in GitHub Desktop.
Generate lines of a specified length using a specified character with Bash
#! /bin/bash
#================================================================================#
# ___ ___ ___ _ __ _____ _ _____ _ _ _____
# | \/ | / _ \ | | / /| ___| | |_ _| \ | || ___|
# | . . |/ /_\ \| |/ / | |__ | | | | | \| || |__
# | |\/| || _ || \ | __|| | | | | . ` || __|
# | | | || | | || |\ \| |___| |_____| |_| |\ || |___
# \_| |_/\_| |_/\_| \_/\____/\_____/\___/\_| \_/\____/
#
#________________________________________________________________________________
#
# makeline.sh
#
# Generate lines of a specified length using a specified character with Bash
# Created by h8rt3rmin8r on 20190127
#
#================================================================================#
# VARIABLE ASSIGNMENTS
LINE_COUNTER=0
CHAR=""
LENGTH=""
# Assign variables based on user inputs
# Generate default fallback variables if no inputs are present
if [[ "x$1" == "x" ]]; then CHAR="="; else CHAR="$1"; fi
if [[ $# -lt 2 ]]; then LENGTH="80"; else LENGTH="$2"; fi
# EXECUTE OPERATIONS
while [[ ${LINE_COUNTER} -lt "${LENGTH}" ]];
do
printf '%s' "${CHAR}"
let LINE_COUNTER=LINE_COUNTER+1
done
#echo
#================================================================================#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment