The symble '-' in Linux

This is a wonderful symble in the linux.
  1. It can change the data stream which would go to a file to the stdout.
  2. It can import the data stream which would come from a file from the stdin.
So, if we use the wonderful '-' combine with the pipe, what will hanpen?

tar -cvf - /home | tar -xvf -

This shell command result is same as the command

mv /home/* ./

The data which would go into a archive is now going to the stdout, then use the pipe to change the stdout as stdin, then use the symble '-' to import the stdin data stream into the 'tar -xvf' command to extract them to now using folder.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章