本文介绍了如何在Ubuntu中使用bash反转文件中的所有单词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想撤消文件中的完整文本.
说文件是否包含:
I would like to reverse the complete text from the file.
Say if the file contains:
com.e.h/float
我希望将输出显示为:
float/h.e.com
我尝试了以下命令:
rev file.txt
但是我得到了所有反向输出:taolf/h.e.moc
有没有办法我可以得到想要的输出.让我知道.谢谢.
这是示例文件的链接:示例文本
but I have got all the reverse output: taolf/h.e.moc
Is there a way I can get the desired output. Do let me know. Thank you.
Here is teh link of teh sample file: Sample Text
推荐答案
是否可以使用Perl?
Is it possible to use Perl?
perl -nlE 'say reverse(split("([/.])",$_))' f
根据PO的标准,这种单线可反转f的所有行.
This one-liner reverses all the lines of f, according to PO's criteria.
如果希望使用括号较少的版本:
If prefer a less parentesis version:
perl -nlE 'say reverse split "([/.])"' f
这篇关于如何在Ubuntu中使用bash反转文件中的所有单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!