Menu

tar: Problem with --exclude-from option

Help
Pete
2005-01-19
2012-07-26
  • Pete

    Pete - 2005-01-19

    Hi,

    I'm having trouble with the --exclude-from option in tar.

    The following works:
    tar -cvf backup.tar --exclude *.exe mydir
    in that .exe files are excluded from the archive.

    But this does not:
    tar -cvf backup.tar --exclude-from exc.txt mydir
    where exc.txt contains the line *.exe.

    What am I doing wrong?

    Platform is Windows 2000 Pro SP4.
    tar is tar-1.13-1.

    Regards,
    Pete A

     
    • Pete

      Pete - 2005-01-21

      I have more info.

      It's a problem with line endings. The --exclude-from option does work if the file has *nix line endings, LF rather than CRLF.

      I'll delve into the source and see if I can post a more specific bug report.

      Regards,
      Pete A

       
    • Pete

      Pete - 2005-01-21

      OK. The file open mode in tar is defaulting to binary, so the CRLF line endings are not being converted to LF. When tar reads the exclude-from file it gets the CR characters in the pattern, and so the patterns don't match.

      The fix lies in the function add_exclude_file() in exclude.c. At the call to fopen(), set the mode parameter to "rt" rather than "r".

      Alternatively, create the exclude-from file with an editor that supports *nix line endings.

      Regards,
      Pete A.

       
MongoDB Logo MongoDB