≡ Menu

printf command

Linux / Unix: Use Cat Command To Append Data To a File

I am a new Unix user. I have Debian Linux installed. I need to append text to a file called daily.log. How do I use the cat command to append data to a file?
[click to continue…]

Unix / Linux: Bash Number Currency Formatting Thousands Grouping Separator

I have a number stored in a shell variable called x="240570.578". I would like to print $x as 2,40,570.57. How do I replace the number with their currency format under bash shell scripts?
[click to continue…]

Unix Create a File Command

I'm a new Unix user. How do I create a file from bash prompt without using GUI tools? How to create a file in Unix from terminal window? What's the easiest and best way to create a file in Unix?
[click to continue…]

Linux / Unix: id Command Examples

id command

I am a new Linux and Unix system user. How do I find out the user and groups names and numeric IDs of the current user or any users on my server? How can I display and effective IDs on the system using command line options? In Linux, how do I find a user's UID or GID?
[click to continue…]

Linux: Set Environment Variable

Bash shell is used for various purposes under Linux. How do I customize the shell environment variable under Linux operating systems?
[click to continue…]

HowTo: Get / Print Current Date in Unix / Linux Shell Script

How do I get the current date in Unix or Linux shell scripting and store it into a shell variable? How do I print the current date using Unix shell script?
[click to continue…]

Linux / UNIX: bc Convert Octal To Hexadecimal or Vise Versa

How do I convert from octal to hex number using bc UNIX / Linux command line utility?
[click to continue…]

Unix / Linux: TCSH / CSH Shell Set Variable

How do I set environment variables using c shell (tcsh or csh) under FreeBSD UNIX or Linux operating systems? How do I save variable using csh shell under Unix like operating systems?
[click to continue…]

Display or print UNIX / Linux path ~ $PATH variable

Q. How do I print current path settings under BASH shell? I’m using Debian Linux.

A. In UNIX / Linux file systems, the human-readable address of a resource is defined by PATH. On Unix / Linux like operating systems, (as well as on DOS / Windows and its descendants), PATH is an environment variable listing a set of paths to directories where executables may be found.

Display current PATH

Use echo command:
$ echo $PATH


Modify current PATH

Use export command to add /opt/games to PATH, enter:
export PATH=$PATH:/opt/games

To format your PATH variable for easy viewing, add following code to your bash startup file (such as ~/.bashrc or ~/.bash_profile) :

function path(){
    printf "%s\n" $PATH

(Function credit: usenet archive)

Now just run path:
$ path


HowTo Format Date For Display or Use In a Shell Script

How do I format date to display on screen on for my shell scripts as per my requirements on Linux or Unix like operating systems?
[click to continue…]