Simple version control script for text files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Simple version control script for text files
# 1  
Old 05-02-2011
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 Smilie
# 2  
Old 05-02-2011
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)
# 3  
Old 05-02-2011
: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
# 4  
Old 05-03-2011
Perhaps you can use something like :
Code:
./script.sh -p file1
./script.sh -p "file1 file2 file3 file4"

Code:
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.
# 5  
Old 05-03-2011
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 https://www.unix.com/shell-programmin...ll-script.html

Best wishes ... cheers, drl
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Rename files based on simple text file

Hello! New here although not completely new to Unix. I wonder how I could rename files based on the data found in a simple textfile. It goes like this: I have 4 files 1 ldfgkkfjslkdfjsldkfjsf.wav 2 nndsdflksdjf.wav 3 sdflksjdf jjsdflsdfl.wav 4 dkadsdddd.wav Textfile.txt looks like... (14 Replies)
Discussion started by: Oortone
14 Replies

2. Programming

Version control for audit

Hi.I am running some scripts from a "scripts" directory for my job (I am working in Financial industry).For compliance purposes I need to use a "release" directory when running them using some sort of version control(CVS,SVN or GIT) in case the program is audited.Basically I have to maintain a dev... (0 Replies)
Discussion started by: rolleikid
0 Replies

3. Shell Programming and Scripting

Create a File for Version Control

Hi , I have to create a file with 3 columns A,B,C. I have to read the column A,B values from a text pad. Where as Column a contains approximately 10 values and column B has 1 value which is constant. Column C is a version control column ,initially the value would be 1. (1 Reply)
Discussion started by: Inform123
1 Replies

4. Shell Programming and Scripting

Version Control Through the Shell Script

Version Control Through the Shell Script Hi Guys, Apologize for the big request, please take some time and read it completely... This is Very important for me, and ur help is Very much Appriciated. I want to maintain the Version control to all my scripts running in Production server, I am... (6 Replies)
Discussion started by: Anji
6 Replies

5. Shell Programming and Scripting

Simple script editing text files and running commands

Okay this will probably have multiple parts to it but I don't really want to trouble you guys with more help because I'm a total noob so I can just do the first part by hand (it's just editing a few hundred lines of text in a file; I have to do the same thing on each line and I'm sure there's a... (2 Replies)
Discussion started by: guitarscn
2 Replies

6. UNIX for Advanced & Expert Users

Maintaining different version Control account

How can I maintain different version control account(any common unix based version control like CVS,RCS,SCCS..) from a single UNIX Login Account. Many programmers share a common UNIX user/login account.How do they maintain separate Version Control Account. (1 Reply)
Discussion started by: johnbach
1 Replies

7. Shell Programming and Scripting

simple script detect to find OS version/flavour

Hi, A newbie question. Following script gives no output. =============================== root@srv # cat /etc/redhat-release | awk {'print $1}' Red root@srv # cat 123.sh if (( `cat /etc/redhat-release | awk {'print $1}'` != CentOS )); then { echo "System runs on Redhat Linux. ... (13 Replies)
Discussion started by: fed.linuxgossip
13 Replies

8. AIX

Randomly appearing control characters in text files

Hi, From some time, we have noticed that our ascii files have started corrupting due to the presence of some random control characters (^@, ^M, ^H, ^D). The characters appear randomly on any file after the process that creates the file finishes. If we rerun the process, the files re creates... (0 Replies)
Discussion started by: aakashahuja
0 Replies

9. UNIX for Dummies Questions & Answers

Version Control

I am not sure if this is the right forum to post my question on Version Control. Anyway, here it is! I use CVS for source code maintainence in my Solaris box. Is there any command where I can find out in CVS, if any check-in/check-out was done in the last 24 hours? I need a listing of all the... (3 Replies)
Discussion started by: Deepa
3 Replies
Login or Register to Ask a Question