1 2 3 4 5 6 7 8 9 10
#!/bin/bash currentTime=$(date -u '+%s') statement= until [ -z "$1" ] # Until all parameters used up . . . do statement="$statement"' '"$1" shift done echo -e $currentTime'\t'$statement >> $HOME/progress/progress.txt
Refactorings
No refactoring yet !
Eineki
July 8, 2008, July 08, 2008 06:09, permalink
Why don't you use the command "script"?
If I understand your question you need a trascript of a command
and script -a - c <command you need> $HOME/progress/progress.txt should do the trick.
By the way script is useful into interactive mode too.
Chris Jester-Young
July 8, 2008, July 08, 2008 11:36, permalink
Here's a one-liner (excluding the shell-bang line) for your enjoyment. :-) The main thing is the use of "$*", which joins all arguments into a single string. The use of printf means you don't have to use "echo -e", which can help readability.
1 2
#!/bin/bash printf '%s\t%s\n' "$(date)" "$*" >> ~/progress/progress.txt
I wanted to store things I was learning into a simple text file. For example, if the command was called ilearned, you could say 'ilearned working on a bash script' and it would store that info. I'm brand new at this...