Simple version control script for text files

HI guys,
Could you help me writing a simple version control script for a text files.
the format could be
./version_control [command] [flags] <file(s)> (I want it to be able to work with more than 1 file at the same time)
commands are add and get, add means you add new file(s) to the archive, get means you get files from the archive.
when you first add the files, a changelog is generated and printed out that simply includes date and timestamped when the file is changed.
when the flag -r is used, for example together with *.c files, it will add all of these files to the archive.
Then you could use a get command to pull the file from the archive and create a copy for your own use, if the file exists in the current directory then you should receive a confirmation to overwrite.
additionally, i would like to be able to view changes history using a command like show.
thank you :slight_smile:

Why not use CVS? It's a precursor to Subversion, Mercurial, Bazaar, git, ... which basically does what you need.

If that's too many features for you already: what have you got so far? (remember, we won't give you complete scripts just because you ask for it)

:P, I'm just trying to learn unix scripting, this is one exercise I found in the book. the problem is they don't have solution in this book.
by the way, I've come up with steps to do it.
can you tell me how to use getopts with full command name, not characters as options?
thank u

Perhaps you can use something like :

./script.sh -p file1
./script.sh -p "file1 file2 file3 file4"
while getopts ":p:" OPTN
do
	case $OPTN in
	p)
            for i in ${OPTARG}
            do
            printf  "working with $i \n"
            done
;;
esac
done

So if you pass "file1 file2 file3 file4", it will iterate and do operations on all 4 files and if you pass only file1 it will do it for for only that one.

Hi.

The most simple set of scripts to do version control that I know of was presented in Kernighan and Pike. See post 7 in Version Control Through the Shell Script

Best wishes ... cheers, drl