bash scripting --- some help needed
Hi all,
I want to write a bash script for some task that will save a lot of time.
Basically given the following file format:
==================================================
The following list of files implement this module.
List of files:
... //repository/usr/local/file1
... //repository/usr/local/dir/file2
... //repository/usr/tmp/file3
some other description.
===================================================
I need to read this file and create a backup of each listed file. But I am having a
hard time reading file path and names. In the above file, === line is not
present in the file (just here for clarity). So in the above example, I need to create
the following backups in /usr/local/backup directory:
/usr/local/file1 -> /usr/local/backup/usr/local/file1.bk
/usr/local/dir/file2 -> /usr/local/backup/usr/local/dir/file2.bk
/usr/tmp/file3 -> /usr/local/backup/usr/tmp/file3.bk
After creating backups, I need to change the group of actual files to "backedUp".
I also want to echo proper messages. So I copy a file, if it is successful (based on the error return code in bash), I want to echo "created backup of this file to this file". If any error occurs in between, I need to roll back all changes. So the entire operation is atomic.
I also want some way to verify output in the end.
Any help on this is highly appreciated.
Raj
|