0

I have following function in order to extract discarding directory structure.

tarx() {
    STRIP=${1%.*}  # strip last suffix
    NAME=${STRIP%.tar}  # strip .tar suffix, if present
    tar -xvf "$1" --xform="s|^|$NAME/|S"
}

$ tarx bone.n26c100.tbz2

Here I want to see progress bar while extracting.

I have tried:

$ pv "$1" | tar -xvf "$1" --xform="s|^|$NAME/|S"
B 0:00:29 [0.00 B/s] [<=>

which does not show the progress change. How can I apply progress bar if tar is using --xform= flag.


Related: https://superuser.com/questions/168749/is-there-a-way-to-see-any-tar-progress-per-file

1 Answer 1

1

You need to tell tar to read from the pipe, not the file:

pv "$1" | tar -xvf - --xform="s|^|$NAME/|S"
2
  • I have to add -j flag due to tar: Archive is compressed. Use -j option error message
    – alper
    Nov 17, 2021 at 14:55
  • 1
    Ah, so you need tar -xjvf - .... Nov 17, 2021 at 14:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .