0

I used -T parameter to write the directory inside the file.

tar -czvf $LOCAL_FILE_SAVE -T $TXT_FILE

It's possible ignore the first lines on txt or use a special key to use like comment?

Example:

#comment (Ignore this line)
/home/user/stack
Cyrus
  • 84,225
  • 14
  • 89
  • 153
  • 1
    Use a tool like `sed`, `awk` or even `find` to generate the desired list of files based on your input file. Then let `tar` [read the files from stdin](https://stackoverflow.com/questions/2597875/how-can-i-build-a-tar-from-stdin) – 0stone0 May 17 '21 at 19:19

1 Answers1

0

I suggest to use bash's Process Substitution with sed to remove first line:

tar -czvf "$LOCAL_FILE_SAVE" -T <(sed 1d "$TXT_FILE")
Cyrus
  • 84,225
  • 14
  • 89
  • 153
  • 1
    I assume `sed 1d "$TXT_FILE" | tar -czvf "$LOCAL_SAVE_FILE" -T -` would work just as well, and be more portable to boot. – chepner May 17 '21 at 19:37