742
社区成员
发帖
与我相关
我的任务
分享
sed "/^[^:]*$/{h;d;b};/^.*$/{G;s/\n/:/g}" data.txt
awk '!/:/{s=$0;next}{$0=$0":"s}1' urfile
$ awk '{if((NR-1)%3==0)v=$0;else print $0":"v}' 1.txt
3:YYSZ:5$0:20130502183025
6:ZWSZ:6$8:20130502183025
3:YYSZ:4$1:20130503193028
6:ZWSZ:6$0:20130503193028
awk 'i%3==0{last=$0} i%3!=0 {print $0 ":" last} {i=i+1}' data.txt
cat data.txt
20130502183025
3:YYSZ:5$0
6:ZWSZ:6$8
20130503193028
3:YYSZ:4$1
6:ZWSZ:6$0
awk 'BEGIN{i=0;}{rec[i]=$0; if(i==2){print rec[1]":"rec[0]"\n"rec[2]":"rec[0];} i=(i+1)%3;}' data.txt
cat test.txt|grep ':' -v|sed 's/^20/:20/'|cat -n|tr -s '\t' ' ' > temp1
cat temp1 temp1 | sort -n -t ' ' -k 2| cut -f3 -d ' '|cat -n|tr -s '\t' ' '|cut -c 2- > temp1
cat test.txt | grep ':'|cat -n|tr -s '\t' ' '|cut -c 2- > temp2
join temp2 temp1 | cut -f2- -d ' '|sed 's/\s:20/:20/' > result
rm temp1
rm temp2