当前位置: 技术问答>linux和unix
sed的使用
来源: 互联网 发布时间:2016-03-24
本文导语: 怎样将一句话中的句尾的单词在第一行显示出来,句首的单词在第二行显示出来 ex: that is my owrk the work has done output: owrk that done the | sed s...
怎样将一句话中的句尾的单词在第一行显示出来,句首的单词在第二行显示出来
ex: that is my owrk
the work has done
output:
owrk
that
done
the
ex: that is my owrk
the work has done
output:
owrk
that
done
the
|
sed s'/^s*(w+).*s(w+)s*$/2n1/'
测试:
[of@lbaby ~]$ sed s'/s*(w+).*s(w+)s*$/2n1/' the work is done
> eof
work
this
done
the
测试:
[of@lbaby ~]$ sed s'/s*(w+).*s(w+)s*$/2n1/' the work is done
> eof
work
this
done
the
|
用awk比较方便,例子:
echo 'that is my owrk' | awk '{print $NF,"n",$1}'
echo 'that is my owrk' | awk '{print $NF,"n",$1}'