# bash
if [ ${ORACLE_HOME:-0} = 0 ]; then
ORACLE_TMP="/tmp"
else
ORACLE_TMP=$ORACLE_HOME/tmp
fi
export ORACLE_TMP
# csh
if ($?ORACLE_HOME == 0) then
setenv ORACLE_TMP /tmp
else
setenv ORACLE_TMP $ORACLE_HOME/tmp
endif
If bash is going to be your preferred shell in Linux, rather than looking for a tool, you might be better served to spend a few minutes learning how to do this in bash. Unless the csh script is really complex, it's not likely to take much effort to translate, and having done that you'll be armed with the knowledge to understand future bash (and csh) scripts better.
A couple of tips to get you started:
in csh, you set environment variables with setenv; bash uses = + export
the if syntax is different between the two
For example:
# bash
if [ ${ORACLE_HOME:-0} = 0 ]; then
ORACLE_TMP="/tmp"
else
ORACLE_TMP=$ORACLE_HOME/tmp
fi
export ORACLE_TMP
# csh
if ($?ORACLE_HOME == 0) then
setenv ORACLE_TMP /tmp
else
setenv ORACLE_TMP $ORACLE_HOME/tmp
endif
if [[ $number -lt 0 ]] ; then
echo What the ...
fi
Yes, post the code. There are hordes of alpha geeks just waiting here to do this sort of work for you, sort of like Rent A Coder but without the cost :-)
Seriously, it's likely to be just the fact that, from memory, csh uses parentheses for conditions while bash uses [[...]] but, until you post the code (at least the offending lines with some context), we can't be sure.
In other words, the csh:
if ($number < 0) then
echo What the ...
endif
would become the bash:
if [[ $number -lt 0 ]] ; then
echo What the ...
fi
发布评论
评论(2)
如果 bash 将成为您在 Linux 中的首选 shell,那么您最好花几分钟学习如何在 bash 中执行此操作,而不是寻找工具。除非 csh 脚本非常复杂,否则翻译起来不太可能花费太多精力,完成后您将掌握更好地理解未来 bash(和 csh)脚本的知识。
一些入门技巧:
setenv
设置环境变量; bash 使用=
+export
例如:
If bash is going to be your preferred shell in Linux, rather than looking for a tool, you might be better served to spend a few minutes learning how to do this in bash. Unless the csh script is really complex, it's not likely to take much effort to translate, and having done that you'll be armed with the knowledge to understand future bash (and csh) scripts better.
A couple of tips to get you started:
setenv
; bash uses=
+export
For example:
是的,贴一下代码。有成群的阿尔法极客在这里等着为你做这类工作,有点像租一个编码器,但没有成本:-)
说真的,这可能只是事实,从记忆中,
csh< /code> 使用括号作为条件,而
bash
使用[[...]]
但是,在您发布代码之前(至少是具有某些上下文的违规行),我们不能确定。换句话说,
csh
:将变成
bash
:Yes, post the code. There are hordes of alpha geeks just waiting here to do this sort of work for you, sort of like Rent A Coder but without the cost :-)
Seriously, it's likely to be just the fact that, from memory,
csh
uses parentheses for conditions whilebash
uses[[...]]
but, until you post the code (at least the offending lines with some context), we can't be sure.In other words, the
csh
:would become the
bash
: