Berchev Berchev - 7 months ago 14
Bash Question

Portable bourne shell script without using functions of modern shells as bash, ksh, zsh etc

First of all I want thank all of you who will help me solve this. I have an exam tomorrow and I have to prepare this script for the exam. I am really new to linux and those bourne shell script.

My project should be a portable bourne shell script which scans a directory for the following files:

header.txt
,
footer.txt
and
content.txt
. The content of the files should be read but ignoring the lines starting with
#
and this content should be used for generating an HTML page with the following header, footer and content. This files can contain any text and/or HTML code but the cannot contain head and body tags. When scanning the directory the script have to compare the date of the last change of the files (
header.txt
,
footer.txt
and
content.txt
) with the date of the last change of the HTML page (if you have one already) and if the date of the last edit on the files is newer than the one on the HTML page the script should generate a new HTML page with the latest content.

Guys thank you very much as this is very important for me. Please help me getting this done.

Thank you very much!

Answer

To remove lines beginning with # try this:

grep -v "^#" file

To remove lines that may contain spaces (or blank characters) before a #:

grep -v "^[[:blank:]]*#" file
Comments