Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!

Notices

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.

So remove it's entry from the list as well or remove all it's child file entries from $list. Also did you check those file really exist or not? If exist, then replace ~ with /home/username. New list should look like:

So remove it's entry from the list as well or remove all it's child file entries from $list. Also did you check those file really exist or not? If exist, then replace ~ with /home/username. New list should look like:

As a side note (and this has nothing directly to do with how to fix your script).

I do understand it can be VERY useful to annotate configuration files like the list of "important files".

You CAN use the comments as you have them, but to do so requires you to remove the comments before sending the data to tar. One way to do this is to use stdin to read the list of important files:

Code:

grep -v '^#' list | tar -T - -cf test.tar

The "-T -" causes tar to read the list from stdin instead of from a disk file. Unfortunately, this usage isn't documented (the -T only lists "FILE" as input). Tar usually allows stdin to substitute for parameters that take a file input... but you can use this syntax only once, so another option taking a file for input can't also take it from stdin.

The grep -v '^#' tells grep to drop lines that start with a #...

This could be preferable to creating a temporary file to contain the list. The grep command can be replaced by anything appropriate for filtering out anything not wanted.

You could even use a "hereis" include to allow shell substitution where you want, but that is a bit more inflexible in that to add/remove entries you have to edit the script instead of the initialization data (but it would allow the ~ to be expanded by the shell).

What's content of $CONFILE, so we can check what and how is this command doing?:
[code]awk 'NR==20,NR==EOF' "$CONFILE" > "$TMP/backuplist.txt" # getting file list[code]

The confile.cfg from row 20 to en of file is:

# Please list the files or directories to be backed up on the next line, hit enter after each line:
~/assignment1/important_files/file1
~/assignment1/important_files/file2
~/assignment1/important_files/file3
~/assignment1/important_files/file9

When I run the script with set -xv I get this near the start (when reading from the confile.cfg)
I have changed to chmod 755 for all files in important_files directory - but is the script trying to run them? why "command not found?" - It seems o work but I am not sure if is working properly?

Thanks (set -xv is great help)

Code:

# Please list the files or directories to be backed up on the next line, hit enter after each line:
~/assignment1/important_files/file1
++ /home/ubuntu/assignment1/important_files/file1
/home/ubuntu/assignment1/important_files/file1: line 1: kjsdf: command not found
/home/ubuntu/assignment1/important_files/file1: line 2: asdfj: command not found
/home/ubuntu/assignment1/important_files/file1: line 3: asdfjasdf: command not found
/home/ubuntu/assignment1/important_files/file1: line 4: asdf: command not found
/home/ubuntu/assignment1/important_files/file1: line 5: asdf: command not found
/home/ubuntu/assignment1/important_files/file1: line 6: asdf: command not found
/home/ubuntu/assignment1/important_files/file1: line 7: bdrtwertewgrt: command not found
/home/ubuntu/assignment1/important_files/file1: line 8: gsbvwgtr: command not found
/home/ubuntu/assignment1/important_files/file1: line 9: bwetbtrw: command not found
/home/ubuntu/assignment1/important_files/file1: line 10: bwdfre: command not found
~/assignment1/important_files/file2
++ /home/ubuntu/assignment1/important_files/file2
/home/ubuntu/assignment1/important_files/file2: line 1: rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr: command not found
/home/ubuntu/assignment1/important_files/file2: line 2: rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr: command not found
/home/ubuntu/assignment1/important_files/file2: line 3: rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr: command not found
/home/ubuntu/assignment1/important_files/file2: line 4: rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr: command not found
~/assignment1/important_files/file3
++ /home/ubuntu/assignment1/important_files/file3
/home/ubuntu/assignment1/important_files/file3: line 1: werefdsfgdsfg: command not found
/home/ubuntu/assignment1/important_files/file3: line 2: dsrrgfdsfg: command not found
/home/ubuntu/assignment1/important_files/file3: line 3: dsfgdfsg: command not found
/home/ubuntu/assignment1/important_files/file3: line 4: ewrterwt: command not found
/home/ubuntu/assignment1/important_files/file3: line 5: sdfgsfdbgsdrtgerw: command not found
/home/ubuntu/assignment1/important_files/file3: line 6: sdfbdsfgf: command not found
~/assignment1/important_files/file9
++ /home/ubuntu/assignment1/important_files/file9
/home/ubuntu/assignment1/important_files/file9: line 1: dsfg: command not found

Running script but not properly - getting all this "output" of file content but is not backing them up properly?

/assignment1.sh
/home/ubuntu/assignment1/important_files/file1: line 1: kjsdf: command not found
/home/ubuntu/assignment1/important_files/file1: line 2: asdfj: command not found
/home/ubuntu/assignment1/important_files/file1: line 3: asdfjasdf: command not found
/home/ubuntu/assignment1/important_files/file1: line 4: asdf: command not found
/home/ubuntu/assignment1/important_files/file1: line 5: asdf: command not found
/home/ubuntu/assignment1/important_files/file1: line 6: asdf: command not found
/home/ubuntu/assignment1/important_files/file1: line 7: bdrtwertewgrt: command not found
/home/ubuntu/assignment1/important_files/file1: line 8: gsbvwgtr: command not found
/home/ubuntu/assignment1/important_files/file1: line 9: bwetbtrw: command not found
/home/ubuntu/assignment1/important_files/file1: line 10: bwdfre: command not found
/home/ubuntu/assignment1/important_files/file2: line 1: rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr: command not found
/home/ubuntu/assignment1/important_files/file2: line 2: rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr: command not found
/home/ubuntu/assignment1/important_files/file2: line 3: rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr: command not found
/home/ubuntu/assignment1/important_files/file2: line 4: rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr: command not found
/home/ubuntu/assignment1/important_files/file3: line 1: werefdsfgdsfg: command not found
/home/ubuntu/assignment1/important_files/file3: line 2: dsrrgfdsfg: command not found