Bash

I‘m using the date +’%D_%T’ to store Unix system date and time in a shell variable called $_now:

_now=”$(date +’%D_%T’)”
echo $_now

Outputs:
01/20/12_16:10:42

I’d like to replace / and : with _. I’m aware of the following sed command:

sed ‘s/\//_/g
> s/:/_/g’ <<<"$_now"

Outputs:
01_20_12_16_14_09

How do I specify two pattern within the same sed command to replace | and : with _ so that I can get output as 01_20_12_16_10_42?

{ 1 comment }

Bash C Style For Loop Example and Syntax

by Vivek Gite on June 7, 2011 · 1 comment

How do I use the bash C style for loop under UNIX or Linux operating systems?

{ 1 comment }

How do I run “foo” command 10 times (or n times) under Linux or UNIX like operating systems?

{ 6 comments }

How do I auto Logout my shell user in Linux after certain minutes of inactivity?

{ 0 comments }

I have a file of that looks as follows:

foo bar
tom jerry
UNIX Linux

Each word and/or Linux is a different length. How do strip or remove the last character from each line using bash or ksh shell only?

{ 3 comments }

How do I change the default home page with Lynx browser under UNIX or Linux operating system? How do I set the startup page to http://google.co.uk with Lynx?

{ 0 comments }

Linux / UNIX: Run Commands When You Log Out

by Vivek Gite on November 23, 2010 · 0 comments

I’ve written a Perl script that connects to our central server for me and it allows me feed data so that I make a timesheet later. How do I run my script when I log out from Apple OS X or Linux / UNIX workstation using bash shell?

{ 0 comments }