Skip to main content
1 of 2

Error with option --strip-components when running example from manual of tar command

When reading the manual of tar command I encountered something wrong with the option --strip-components. The example in the manual is that there is a tar file containing a directory with 3 files. When listed with the tar command it looks like this:

$tar -tf music.tar
practice/
practice/blues
practice/folk
practice/jazz

The manual says the --strip-components option
allow you to strip away a certain number of leading directory components
and
$ tar --extract --file=music.tar --strip-components=1 folk
will extract the file ‘folk’ into the current working directory.
But when I run this command on Ubuntu, I got this error

tar: folk: Not found in archive
tar: Exiting with failure status due to previous errors

And my tar version is 1.34.
Besides, I got file folk extracted successfully when I executed the command below
$ tar --extract --file=music.tar --strip-components=1 practice/folk
Did I have some misunderstanding about the manual and option --strip-components? Or is there something wrong with the manual?