Date: Fri, 20 May 2016 20:49:29 +0200 From: Polytropon <freebsd@edvax.de> To: byrnejb@harte-lyne.ca Cc: freebsd-questions@freebsd.org Subject: Re: history utility Message-ID: <20160520204929.3209046e.freebsd@edvax.de> In-Reply-To: <af5631f60eb1e33606eaf16362835193.squirrel@webmail.harte-lyne.ca> References: <af5631f60eb1e33606eaf16362835193.squirrel@webmail.harte-lyne.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 20 May 2016 14:17:09 -0400, James B. Byrne wrote: > As is no doubt obvious from what I am trying to do I come from a bash > background. > > While logged in as root I run the history command and see this: > > # history > 1 20:02 date 12:13:30 > 2 20:03 date 121350 > 3 13:51 man adjtime > 4 13:51 apropos clock > 5 13:52 apropos time > 6 13:53 man adjkerntz > 7 13:58 man clock > 8 13:58 man hwclock > 9 14:00 man date > . . . Which shell is this? What does "echo $SHELL" report, and which shell is defined for this user account in /etc/passwd's shell field? Just to be sure... > I am used to bash and have this in my root .bash_profile on other > systems. > > # Timestamp History > export HISTTIMEFORMAT='%F %T: ' > > Looking in the default ~/.profile I see this: > > # $FreeBSD: releng/10.3/etc/root/dot.profile 199243 2009-11-13 > 05:54:55Z ed $ > # > PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:~/bin > export PATH > HOME=/root > export HOME > TERM=${TERM:-xterm} > export TERM > PAGER=more > export PAGER > > Which to me implies that adding this should work. > > echo "export HISTTIMEFORMAT='%F %T: '" >> .profile Yes, this should work, if bash uses .profile. If I remember correctly, it doesn't - instead it reads .bash_profile. See "man bash" for the difference of .bash_profile and .bashrc. > But nooo. What I see from source .profile is: > > PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:~/bin: > Command not found. > export: Command not found. > HOME=/root: Command not found. > export: Command not found. > Bad : modifier in $ (-). > > Which tells me that .profile is either processed differently than I > expect or not at all. This looks strange. You'll get this if you feed those commands to the C shell (which doesn't use export, but setenv, and has a different initialization file, .cshrc or .login). Try with bash: $ history [...] 500 history $ export HISTTIMEFORMAT='%F %T: ' $ history [...] 502 2016-05-20 20:41:15: history This probably is what you've expected. Now let's try C shell: % history [...] 178 20:44 history % export HISTTIMEFORMAT='%F %T: ' export: Command not found. To be expected. > So, my questions are: > > What is the purpose of .profile? This is the profile file for /bin/sh, FreeBSD's default scripting shell, and dialog shell for maintenance mode. It's a rewrite of the classic Bourne shell, the (quite limited) predecessor of bash. > How is it used? As explained in "man sh". :-) > Why is there no export command found given that man sh explicitly > mentions the builtin command 'export'? Because it seems that you've issued the export command to the C shell, which does not have it. Regarding history timestamps, I think that the C shell does not have that feature. However, you can use bash which obviously implements it. You just need to start bash. ;-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160520204929.3209046e.freebsd>