Runtime exec 执行linux find 命令时 引号问题

环境: Distributor ID: CentOS、java

linux 中使用find 命令

find /opt/test -name '*abc'

假设在这个命令在终端中可以找到 123abc

但是用java程序中 

String str="find /opt/test -name '*abc'"

Runtime.exec(str)

得不到查找结果 (按理说*需要转义要加引号)

原因:不明(又明白的朋友可以告诉一声)

解决方法:
String str=”find /opt/test -name *abc"

可以得到结果123abc




猜你喜欢

转载自blog.csdn.net/zjh1n795/article/details/17071459
今日推荐