3bcace48cdfd67d37cc5516b86efdc0a

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...

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 !

5a00a3a98dcf6f9cd717440fd2b606e5

Eineki

July 8, 2008, July 08, 2008 06:09, permalink

1 rating. Login to rate!

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.

729442eea8d8548842a6e0947e333c7b

Chris Jester-Young

July 8, 2008, July 08, 2008 11:36, permalink

3 ratings. Login to rate!

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

Your refactoring





Format Copy from initial code

or Cancel