shell variable

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 }

How do I count and print particular character (say D or digit 7) in a string or variable under Bash UNIX / Linux shell?

{ 6 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 }

HowTo: Get Current Time In Shell Script

by Vivek Gite on May 25, 2009 · 0 comments

How do I get current server time in shell script?

{ 0 comments }

Bash Shell Loop Over Set of Files

by Vivek Gite on May 11, 2008 · 30 comments

How do I run shell loop over set of files stored in a current directory or specified directory?

{ 30 comments }

Q. I need to find file permission and store the same to a shell variable. How do I find out the file permission without parsing ls -l output? A. Use GNU stat command to display file or file system status. It has option to display output in specific format. Display stat for /etc/passwd file Type [...]

{ 2 comments }