help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shifting a block of text


From: Chris F.A. Johnson
Subject: Re: Shifting a block of text
Date: Wed, 8 Dec 2021 03:45:38 -0500 (EST)
User-agent: Alpine 2.22 (DEB 394 2020-01-19)

On Wed, 8 Dec 2021, fatiparty--- via wrote:


Dec 8, 2021, 07:40 by fxmbsw7@gmail.com:

...
shifted-block "Phrase 1" "Phrase 2" "Phrase 3"
Print  phrases without any leading spaces (uses nc=0)

shifted-block 8 "Phrase 1" "Phrase 2" "Phrase 3" ...
Print phrases on separate lines with 8 leading spaces (uses nc=8)

shifted-block()
{
  case $1 in
    *[!0-9]*) ;;
    *) padding=$1
       shift ;;
  esac
  printf -v pad "%${padding}.${padding}s" ' '
  fmt=$pad%s'\n'
  printf "$fmt" "$@"
}

--
   Chris F.A. Johnson


reply via email to

[Prev in Thread] Current Thread [Next in Thread]