Python 脚本能完全代替 shell 脚本的工作吗?

2017 年 4 月 24 日
 superPershing

shell 的不少工作都能由 Python 来代替(个人愚见。。),那么在日常开发中,在 linux 下能完全用 Python 代替 shell 编程吗?请各位大佬来打击我的说法,让菜鸟开阔一下眼界。

10107 次点击
所在节点    编程
25 条回复
Finest
2017 年 4 月 24 日
可以
superPershing
2017 年 4 月 24 日
@hand515 那是不是说在某种程度上没有学 shell 的必要了?
jtsai
2017 年 4 月 24 日
@superPershing 学 shell 是学 shell 的思想,怎么跟 liunx 打交道。不学 shell 你也不知道怎么用 Python 跟 linux 打交道
holyghost
2017 年 4 月 24 日
@superPershing 当然

以前是 perl 在某种程度上承担了替代 shell 脚本的功能(当然 perl 自己说初衷是为了搞死 awk 和 sed ),现在是 python
BOYPT
2017 年 4 月 24 日
(这就是你不学习 shell 的借口嘛!
FunctionOne
2017 年 4 月 24 日
#! /usr/bin/env python

这个……
FunctionOne
2017 年 4 月 24 日
这个谁来解释呢?
SuperMild
2017 年 4 月 24 日
不仅 Python ,甚至用 Java 都可以,有人这样做了:
https://www.teamten.com/lawrence/writings/java-for-everything.html
bozong
2017 年 4 月 24 日
Finest
2017 年 4 月 24 日
@superPershing

不学 shell ,你在 linux 下的工作效率会下降很多
heiybb
2017 年 4 月 24 日
@bozong 这个回复意义何在…
jinghangdayunhe
2017 年 4 月 24 日
@bozong 啥好东西?
imn1
2017 年 4 月 24 日
“完全”是不能的,除非你想降低效率

例如
cat text.txt

ls ../*.txt

python 如何提高效率
tammy
2017 年 4 月 24 日
我想说 python shell 也是 shell 啊,楼主你说的是 posix shell?
bozong
2017 年 4 月 24 日
@heiybb #11
@hand515 #10 Ctrl+V 按快了。 也删不了。
kmyzzy
2017 年 4 月 24 日
试试 xonsh ,支持 shell 命令,也支持 python 语法
Marfal
2017 年 4 月 24 日
@bozong #15 微博图床的弊端:不能删 hhh
lucifer9
2017 年 4 月 24 日
绝对可以吧,如果有不行的,请呼叫 os.system
geelaw
2017 年 4 月 24 日
这俩玩意儿难道不是平凡地互相归约么?互相调用并不困难吧
dacapoday
2017 年 4 月 24 日
更完善的说是用 ipython 代替 shell ,而且 ipython 中 !开头的语句当做 shell 执行,从而兼顾 shell 便利和 python 的强大。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://v2ex.ih06.com/t/356992

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX