Loading

shell中标题打印

#!/bin/bash

function title_print ()
{
  terminal_width=$(stty size|cut -d' ' -f2)
  title=$1
  title_length=$(echo $title|wc -L)
  pre_length=$[($terminal_width-$title_length)/2 - 1]
  yes "#" | sed $pre_length'q' | tr -d '\n'
  echo -n " "$title" "
  yes "#" | sed $pre_length'q' | tr -d '\n'
  echo ''
}

# title_print "I am title"
posted @ 2023-02-21 17:21  小维江湖  阅读(35)  评论(0编辑  收藏  举报