Installing gnu-tar on Mac

Fullsour
Fullsour
Sep 3, 2017 · 2 min read

Mac is built based on BSD by default. So, we can use a bunch of command on Linux without installing. But, if you use Mac with CentOS in parallel, you will get trouble which caused by the difference between Mac and CentOS environments.

The other day, I tried to transfer the data to Amazon Linux. At that time, I archived it to improve the speed of transfer and minimize size. After that, I tried to decompress that on CentOS environment. Archiving surely worked. But some errors were shown.

$ tar xzvf example.tar.gz
tar: 未知の拡張ヘッダキーワード `SCHILY.dev' を無視
tar: 未知の拡張ヘッダキーワード `SCHILY.ino' を無視
tar: 未知の拡張ヘッダキーワード `SCHILY.nlink' を無視

According to my research, if I contain multi-byte text name file in my tar file, it’s caused. It seems happened due to the difference between MacOS tar command and CentOS tar command.

# tar on my Mac
bsdtar 2.8.3 - libarchive 2.8.3
# tar on my CentOS
tar (GNU tar) 1.26

Installing gnu-tar on Mac

To synchronize environments, I installed gnu-tar on my Mac. The way is just to use brew.

brew install gnu-tar

If you haven’t installed the brew command, see this site and install it.

Then, you can use gtar command on your Mac

gtar --version
tar (GNU tar) 1.29

If I use this command on Mac to archive, it surely functioned. And archived data works well on my CentOS environment.

# on Mac
$ gtar czvf example.tar.gz example
example/
example/テスト.txt
# send it to CentOS
# login to CentOS
$ tar xzvf example.tar.gz
example/
example/テスト.txt

Looks good :)

References:

Fullsour

Written by

Fullsour

Senior Front End Architect / Freelance, self-employed

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade