Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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:
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.
so where are you actually stuck? (those ==='s are not for clarity btw..!) if you have this simple list file then accessing each line is just down to the contents of a for loop:
for file in $(cat /blah/something/backups)
echo backing up $file to /usr/local/backup/$file.bk
cp $file /usr/local/backup/$file.bk
if [$? -ne 0 ] then
echo error in last backup attempt
chown backup:backup /usr/local/backup -R
something like that will suffice maybe?
I really hope this is a real question and not homework...