From owner-freebsd-questions@freebsd.org Fri May 20 18:49:40 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 046E8B4387E for ; Fri, 20 May 2016 18:49:40 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 99C3D1E29 for ; Fri, 20 May 2016 18:49:39 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de (port-92-195-121-20.dynamic.qsc.de [92.195.121.20]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx02.qsc.de (Postfix) with ESMTPS id 5B223276D4; Fri, 20 May 2016 20:49:30 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id u4KInTRt002711; Fri, 20 May 2016 20:49:29 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Fri, 20 May 2016 20:49:29 +0200 From: Polytropon To: byrnejb@harte-lyne.ca Cc: freebsd-questions@freebsd.org Subject: Re: history utility Message-Id: <20160520204929.3209046e.freebsd@edvax.de> In-Reply-To: References: Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 May 2016 18:49:40 -0000 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, ...