- 论坛徽章:
- 0
|
本帖最后由 runintostar 于 2014-02-13 17:54 编辑
- awk 'BEGIN{srand()}/<aaa>/{i=0;r=rand()NR;b[r][i++]=$0}!/<aaa>/{b[r][i++]=$0}END{for(x in b){for(i=0;i<length(b[x]);i++){print b[x][i]}}}'
复制代码 回复 1# walkman660
好吧。我表示不知道问题出在哪,二维数组不支持?看来你是unix,Sorry- $ awk 'BEGIN{srand()}/<aaa>/{i=0;r=rand()NR;b[r][i++]=$0}!/<aaa>/{b[r][i++]=$0}END{for(x in b){for(i=0;i<length(b[x]);i++){print b[x][i]}}}' tt
- <aaa>
- abcdefg
- abcdefg
- hijklmn
- <aaaed>
- <aaa>
- abcdefg
- abcdefg
- abcdefg
- abcdefg
- <aaaed>
- <aaa>
- abcdefg
- abcdefg
- <aaaed>
- <aaa>
- abcdefg
- <aaaed>
复制代码 |
|