题解 | #shell将字段逆序输出文件的每行#
将字段逆序输出文件的每行
http://www.nowcoder.com/practice/e33fff83fd384a21ba67f3104fb8d646
#! /usr/bin/env bash
########################################################
#
#
########################################################
function solution() {
awk -F ":" '{
for (i=1; i<=NF; i++) {
if (i==1) {
str = $1; continue
}
str = sprintf("%s:%s", $i, str)
}
print(str)
}' nowcoder.txt
}
solution