How to always display date/time regardless of directory?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to always display date/time regardless of directory?
# 1  
Old 06-09-2009
How to always display date/time regardless of directory?

I found via Google a way to show the date and time stamp once I log in. However, whenever I cd to another directory it doesn't display the correct path.

Here are the relevant parts from my .kshrc :

Code:
unset _h _m _s
eval $(date "+_h=%H ;_m=%M ;_s=%S")
((SECONDS = 3600*${_h#0}+60*${_m#0}+${_s#0}))
typeset -Z2 _h _m _s
_tsub="(_m=(SECONDS/60%60)) == (_h=(SECONDS/3600%24)) + (_s=(SECONDS%60))"
_timehm='${_x[_tsub]}$_h:${_m}'
_timehms='${_x[_tsub]}$_h:$_m:${_s}'
PS1="$_timehms $ "
export INFORMIXSERVER='{REDACTED}'
#PS1="$LOGNAME@$HOSTNAME:$PWD:$VIEW [$(date +"%m/%d/%Y") $_timehms] > "
PS1="PWD:$VIEW [$(date +"%m/%d/%Y") $_timehms $] > "

The last instance of PS1= shows my /u directory and keeps the date/time display. I need to replace this with the current path.

I'm a unix/linux n00b and just an end user with curiousity and no root access.

We're using AIX.

Any help is appreciated

Last edited by vbe; 06-09-2009 at 10:55 AM.. Reason: added code tag
# 2  
Old 06-09-2009
Code:
PS1="$PWD:$VIEW [$(date +"%m/%d/%Y") $_timehms $] > "
/home/vbe: [06/09/2009  $] >

Youre missing a $ in front of PWD...
# 3  
Old 06-09-2009
Sorry, I'd gone back and added that after posting. It's still not working for me. Here's my .kshrc. I'm posting this in hopes that something I didn't initially include is causing my problem.

Code:
function _cd {
  "cd" "$@"
  es=$?
 PS1="$INFORMIXSERVER:$PWD> "

return $es
    }

     _cd
     alias cd=_cd


unset _h _m _s
eval $(date "+_h=%H ;_m=%M ;_s=%S")
((SECONDS = 3600*${_h#0}+60*${_m#0}+${_s#0}))
typeset -Z2 _h _m _s
_tsub="(_m=(SECONDS/60%60)) == (_h=(SECONDS/3600%24)) + (_s=(SECONDS%60))"
_timehm='${_x[_tsub]}$_h:${_m}'
_timehms='${_x[_tsub]}$_h:$_m:${_s}'

PS1="$_timehms $ "

export INFORMIXSERVER='{REDACTED}'

#PS1="$LOGNAME@$HOSTNAME:$PWD:$VIEW [$(date +"%m/%d/%Y") $_timehms] > "

PS1="$HOSTNAME:$PWD:$VIEW [$(date +"%m/%d/%Y") $_timehms] > "


#export INFORMIXSERVER='{REDACTED}'


alias {REDACTED}='
export INFORMIXSERVER='{REDACTED}'

#PS1="$INFORMIXSERVER->"'
#PS1="$PWD:$VIEW [$(date +"%m/%d/%Y") $_timehms] > "
#PS1="$LOGNAME@$HOSTNAME:$PWD:$VIEW [$(date +"%m/%d/%Y") $_timehms] > "


export LPDEST= {REDACTED}
export PRINTER= {REDACTED}
export DBPRINT=lp


All this shows is {host}:/{curremt pwd value}

Last edited by Franklin52; 06-09-2009 at 11:11 AM.. Reason: Please add code tags!
# 4  
Old 06-09-2009
Anyway whats wrong with just:
Code:
PS1=`uname -n`':$PWD '`date +"%D-%T"`' > '

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Display Date and Time in GDB

In gdb is there any way we can display date/time in first column while debugging or is there any command which will print date/time? I am asking this just to know when exactly a breakpoint got hit. (6 Replies)
Discussion started by: rupeshkp728
6 Replies

2. Shell Programming and Scripting

How to extract latest file by looking at date time stamp from a directory?

hi, i have a Archive directory in which files are archived or stored with date and time stamp to prevent over writing. example: there are 5 files s1.txt s2.txt s3.txt s4.txt s5.txt while moving these files to archive directory, date and time stamp is added. of format `date... (9 Replies)
Discussion started by: Little
9 Replies

3. Shell Programming and Scripting

Display files created on particular date & time

Hi , I have BASH system & i am trying to display the files created on a particular date and time, and after displaying those files I also want to delete all those files.Can anyone of you help me out for this............. Thanx Original post contents restored... Please do not erase the question... (3 Replies)
Discussion started by: rakeshtomar82
3 Replies

4. UNIX for Dummies Questions & Answers

How to display only Owner and directory/sub directory names under particular root

hai, I am new to Unix, I have a requirement to display owner name , directory or sub directory name, who's owner name is not equal to "oasitqtc". (here "oasitqtc" is the owner of the directory or sub directory.) i have a command (below) which will display all folders and sub folders, but i... (6 Replies)
Discussion started by: gagan4599
6 Replies

5. Shell Programming and Scripting

date and time to display on the terminal

hi all, am trying to 'grep' some text from a log file and use the 'cut' command to read from that line i just grep'ed to extract date/time and response times. code sniplet i am using is : grep -i 'text to grep' Out.log | while read LINE; do ... (11 Replies)
Discussion started by: cesarNZ
11 Replies

6. Shell Programming and Scripting

How do i collect date and time for list of files in a directory

How do i collect date and time for list of files in a directory using AWK Command (4 Replies)
Discussion started by: laknar
4 Replies

7. AIX

Unable to display the date-time in seconds on AIX

Hi, In unix the command "date +%s" displays the date-time in seconds since â00:00:00 1970-01-01 UTCâ (a GNU extension) when executed on unix: -sh-2.05b$ date +%s 1152092690 I tried with all the format control output but unable to display the date-time in seconds i,e as in unix format. Can... (6 Replies)
Discussion started by: me_haroon
6 Replies

8. Solaris

display date n Time

Hi Friends, Can any one guide me regarding 'Display the date and time' command other than the command 'date' thanks n regards SsRrIi (1 Reply)
Discussion started by: SsRrIi
1 Replies

9. Programming

problem deleting date-time stamped file in a directory

I have a number of files of the format filename.xfr_mmddyy_%H%M%S which i get in a specified directory daily. Now i want to search in the specified directory & delete the files which are more than 2 days old .So I use a command find $DIR/backup/* -ctime +2 -exec rm -f {} \; But after executing... (1 Reply)
Discussion started by: dharmesht
1 Replies

10. UNIX for Dummies Questions & Answers

Script to display last login date/time?

I was wondering if anyone had a script that would display the last time a user logged into a particular machine. I know about the "last" command, but it gives too much info.... I just wanted to know the last time a user used his/her id. ANy help would be greatly appreciated. Ryan (3 Replies)
Discussion started by: ryaneverett5
3 Replies
Login or Register to Ask a Question