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 $@
execute ls -la , append $date: ls -la log filecode:./script 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.code:$ cat log.txt tue nov 15 11:03:25 cet 2011: ls -la
can similar last command entered. if want record after fact do
!! = last commandcode:echo $(date): !! >> log.txt
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk Basic journal script with bash
Ubuntu
Comments
Post a Comment