Before I sorted out some of the grep, sed, and awk articles, of course, it was a very basic thing, and the problems I encountered would be sorted together, and then analyzed, so the impression would be deeper.
[[email protected] ~]# cat file
1
2
3
4
5
6
7
8
9
10
11
Turn the column first and write the 5 methods:
1.xargs implementations
[email protected] ~]# cat file |xargs
1 2 3 4 5 6 7 8 9 10 11
2.tr implementation, echo wrap required
[email protected] ~]# cat file |tr "\ n" ""; Echo
1 2 3 4 5 6 7 8 9 10 11
3.awk implementation. It is mainly the dynamic setting of Ors, and the ingenious use of "%" redundancy.
[[email protected] ~]# awk ' {if (nr%11) {ors= ""}else{ors= "\ n"};p rint;} ' file
1 2 3 4 5 6 7 8 9 10 11
[Email protected] ~]# awk ' ors=nr%11? ":" \ n "{print} ' file
1 2 3 4 5 6 7 8 9 10 11
4.perl implementations
[email protected] ~]# cat file |perl-pe ' s/\n//'; echo
1 2 3 4 5 6 7 8 9 10 11
5.sed is implemented with N, a few lines will write a few n, here is 10 n
[email protected] ~]# cat file |sed ' N; N N N N N N N N n;s/\n//g '
1 2 3 4 5 6 7 8 9 10 11
This article is from "Kaka West" blog, please be sure to keep this source http://whnba.blog.51cto.com/1215711/1686121
Methods such as SED and awk to make rows