UNIX

mihalis's picture

Using tar

This blog post will try to show you how to use the tar utility.

Look at the contents of the code directory:

$ ls -l code/
total 24
-rw-r--r--@ 1 mtsouk staff 50 Nov 16 18:12 generatePassword.go
-rw-r--r--@ 1 mtsouk staff 50 Nov 16 18:12 randomNumbers.go
-rw-r--r--@ 1 mtsouk staff 50 Nov 16 18:12 stack.go

You can create a new tar file as follows:

$ tar zcvf code.tar.gz code
a code
a code/generatePassword.go
a code/randomNumbers.go
a code/stack.go
$ ls -l code.tar.gz
-rw-r--r-- 1 mtsouk staff 494 Nov 24 22:38 code.tar.gz

The preceding file is also compressed using the gzip utility because of the z option.
You can list the contents of an existing tar file (t) as follows:

$ tar ztvf code.tar.gz
drwxr-xr-x 0 mtsouk staff 0 Nov 10 20:32 code/
-rw-r--r-- 0 mtsouk staff 50 Nov 16 18:12 code/generatePassword.go
-rw-r--r-- 0 mtsouk staff 50 Nov 16 18:12 code/randomNumbers.go
-rw-r--r-- 0 mtsouk staff 50 Nov 16 18:12 code/stack.go

You can extract (x) an existing tar file as follows:

$ tar zxvf code.tar.gz
x code/
x code/generatePassword.go
x code/randomNumbers.go
x code/stack.go

Tags: 
mihalis's picture

Linux User and Developer issue 150

I wrote "Write a book in LaTeX" for Linux User and Developer issue 150.

I also wrote "Get your network information using lsof" for Linux User Developer issue 150.

Image: 
mihalis's picture

Installing older package in HomeBrew

As I am using unison and a Linux machine for backing up my files, unison is very important to me. After Homebrew updated unison, I got the following error message:

$ unison articles
Contacting server...
mtsouk@linode's password:
Fatal error: Received unexpected header from the server:
expected "Unison 2.48\n" but received "Unison 2.40\n\000\000\000\000\017",
which differs at "Unison 2.40".
This can happen because you have different versions of Unison
installed on the client and server machines, or because
your connection is failing and somebody is printing an error
message, or because your remote login shell is printing
something itself before starting Unison.

The solution to the problem was using the older version of unison. This can be done as follows:


$ brew tap homebrew/boneyard
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-boneyard'...
remote: Counting objects: 723, done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 723 (delta 2), reused 1 (delta 0)
Receiving objects: 100% (723/723), 174.67 KiB | 100.00 KiB/s, done.
Resolving deltas: 100% (338/338), done.
Checking connectivity... done.
Tapped 68 formulae
$ cd /usr/local/Library/
$ brew versions unison
Warning: brew-versions is unsupported and will be removed soon.
You should use the homebrew-versions tap instead:
https://github.com/Homebrew/homebrew-versions


2.48.3 git checkout 9eac7e1 /usr/local/Library/Formula/unison.rb
2.40.102 git checkout 3ceb6b0 /usr/local/Library/Formula/unison.rb
2.40.63 git checkout 3c5ca25 /usr/local/Library/Formula/unison.rb
2.40.61 git checkout 5e494c2 /usr/local/Library/Formula/unison.rb
2.32.52 git checkout f724ba8 /usr/local/Library/Formula/unison.rb
MacBook:Library mtsouk$ brew uninstall unison
Uninstalling /usr/local/Cellar/unison/2.48.3...

Last, you install the older unison package:

$ brew uninstall unison
Uninstalling /usr/local/Cellar/unison/2.48.3...
MacBook:Library mtsouk$ pwd
/usr/local/Library
MacBook:Library mtsouk$ git checkout 3ceb6b0 /usr/local/Library/Formula/unison.rb
MacBook:Library mtsouk$ brew install unison
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/unison-2.40.102.yosem
######################################################################## 100.0%
==> Pouring unison-2.40.102.yosemite.bottle.1.tar.gz
/usr/local/Cellar/unison/2.40.102: 6 files, 3.1M

Also found this: http://www.spotwise.com/2015/01/06/broken-unison-brew-on-yosemite/

mihalis's picture

I wrote 2 articles for LUD issue 146

I wrote two articles for Linux User & Developer issue 146!

Title 1: "How to Handle UNIX Signals".

Title 2: "3D Rendering with WebGL".

Image: 

Pages

Subscribe to RSS - UNIX