Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I enjoy learning how to modify files with awk, sed, and bash. However, I know it could cause issues down the road and I would like to be prepared with a log inside the file. I was thinking about how I could create a log in the footer after I modify an .html file but I am unsure how or what the process is called. I would like to be able to do as follows:

line break after the very last line of code
comment tag <!--
each item modifed on a line
end comment tag -->

Example:

<html>
<head>
</head>
<body>
<div class="example">This is before script</div>
</body>
<html>

<html>
<head>
</head>
<body>
<!--<div class="example">This is after script</div>-->
</body>
<html>

<!--
Change date 2012-12-20 13:13
Commented out example
-->
share|improve this question
3  
You need to be more specific about what exactly you are trying to do. If you just want revision control there are many existing tools that already exist for that, although some initial learning curve overhead might be required. –  jw013 Dec 20 '12 at 19:04
    
@jw013 added example –  Matt Dec 20 '12 at 19:20
    
As @ChrisDown has said, just go with a version control system. No need to reinvent existing, sophisticated wheels crudely (it takes a lot of time to implement an efficient and robust VCS). –  jw013 Dec 20 '12 at 19:23
    
I didn't realize I needed a VCS to detect the last line. I think LOG may be a bad choice to use in this case but I am unsure on how to identify what I am trying to do. If I can figure out how to detect the last line and skip a line I can achieve what I want. –  Matt Dec 20 '12 at 19:25

1 Answer 1

up vote 4 down vote accepted

It sounds like you're looking for a very crude form of revision control. You'd do better to look into using a VCS like git.

Once you've got git installed, it's fairly simple to do what you want:

git init # Initialise the new repository

# ... change some files ...

git add file1 file2                # Add files to context
git commit -m 'Changed something'  # Commit (think "restore point")

You can then see previous commits with git log and git show as appropriate.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.