Skip to main content

Thread: Basic journal script with bash


i played around bash bit few months ago, , sadly i've forgotten of learned. 1 of things came across , learned create journal script that, every time typed command in, bring file , insert current date/time @ end. @ time didn't need it, did practice, come in handy.

question is, happen have script on hand, or know how whip 1 up? or @ least know source of such thing, can set myself. remember how set aliases own commands, actual programming itself, i'm lost.

something like
code:
#!/bin/bash  echo $(date): $@ >> log.txt $@
?

code:
./script ls -la
execute ls -la , append $date: ls -la log file

code:
$ cat log.txt tue nov 15 11:03:25 cet 2011: ls -la
there problems though, example globs: ./script ls *.jpg pass not *.jpg param whole list of matching files (bash expand before passing inside). you'd have '*.jpg'. whitespaces problematic.

can similar last command entered. if want record after fact do
code:
echo $(date): !! >> log.txt
!! = last command


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk Basic journal script with bash


Ubuntu

Comments

Popular posts from this blog

Upgrade 3.4.8 to 3.5.1 failed "download package failed" - Joomla! Forum - community, help and support

Joomal 3.6.3 update error - PHP temporary folder is not set - Joomla! Forum - community, help and support

Fatal error during instalation - Joomla! Forum - community, help and support