Linux-admin-paste-command

提供:Dev Guides
移動先:案内検索

Linux Admin-貼り付けコマンド

*paste* コマンドは、ファイルの行をマージするために使用されます。 一般的に使用されるスイッチは次のとおりです。
Switch Action
-d Specify delimiter
-s Paste one file at a time instead of in parallel

_-s_スイッチを明確に理解するための最良の例は、それを見ることです-

[root@centosLocal Documents]# cat myOS.txt && cat lines.txt
Linux
Windows
Solaris
OS X
BSD
line 1
line 2
line 3
line 4
line 5
[root@centosLocal Documents]# past myOS.txt lines.txt

[root@centosLocal Documents]# paste myOS.txt lines.txt
Linux   line 1
Windows line 2
Solaris line 3
OS X    line 4
BSD line 5

[root@centosLocal Documents]# paste -s myOS.txt lines.txt
Linux   Windows Solaris OS X    BSD
line 1  line 2  line 3  line 4  line 5
[root@centosLocal Documents]#

したがって、2つの異なるファイルを組み合わせて「:」コロンまたはタブ区切りファイルが必要な場合は、_paste_コマンドを使用すると、これが非常に簡単になります-

[root@centosLocal Documents]# paste -d":"  myOS.txt lines.txt
Linux:line 1
Windows:line 2
Solaris:line 3
OS X:line 4
BSD:line 5

[root@centosLocal Documents]# paste -d"\\t"  myOS.txt lines.txt
Linux   line 1
Windows line 2
Solaris line 3
OS X    line 4
BSD line 5
[root@centosLocal Documents]#

_paste_を使用すると、ファイルを簡単に取得し、タブ区切りの列にすることができます-

[root@centosLocal Documents]# paste -d"\t" - - < lines.txt
line 1  line 2
line 3  line 4
line 5
[root@centosLocal Documents]#