Shell Script To Display The Text Entered By The User in Bold

Write a shell script to display the text entered by the user in bold?

You need to use the tput utility to display text in bold. It uses the terminfo database to make the values of terminal-dependent capabilities and information available to the shell, to initialize or reset the terminal, or return the long name of the requested terminal type. tput bold turns on bold (extra bright) mode.

#!/bin/bash
# Script to display the text entered by the user in bold
# -------------------------------------------------------------------------
# Copyright (c) 2005 nixCraft project <http:>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# ----------------------------------------------------------------------
# read man page of tput command.
echo -n "Enter text : "
read text
echo "Here is what you entered "
# use tput command to display it in bold
tput bold
echo "$text"
echo -n "Press any key to continue..."
# okay turn of bold effect
read key
# it will clear screen too
tput reset
Get the latest tutorials on SysAdmin, Linux/Unix, Open Source, and DevOps topics:
CategoryList of Unix and Linux commands
File Management cat
Firewall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilities dig host ip nmap
OpenVPN CentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Manager apk apt
Processes Management bg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searching grep whereis which
User Information groups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPN CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one
  • Ghulam M Dec 22, 2011 @ 10:28

    This worked as i needed..Thanks…

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.