by Vivek Gite on January 20, 2012 · 1 comment
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?
How do I count and print particular character (say D or digit 7) in a string or variable under Bash UNIX / Linux shell?
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?
How do I get current server time in shell script?
Q. I’m using FreeBSD 7 with csh (tcsh) shell. How do I export shell variable under FreeBSD operating systems?
How do I run shell loop over set of files stored in a current directory or specified directory?
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 [...]