永发信息网

Shell脚本中对函数的调用

答案:2  悬赏:60  手机版
解决时间 2021-01-29 08:58
  • 提问者网友:心如荒岛囚我终老
  • 2021-01-28 10:31
如果想将一个脚本的查询结果过滤出来,如何将这一过程写到脚本里用函数调用?

脚本a.sh
tbl_name=$1
sqlplus oapapp/OAPAPP@ccb_oap << !

select table_name||','||column_name||','||data_type||','||data_length from user_tab_columns where table_name = '$tbl_name';

!

sh a.sh 表名 |grep 表名(想将这条命令放入脚本内用函数调用)
最佳答案
  • 五星知识达人网友:孤独的牧羊人
  • 2021-01-28 12:02
可以将
sqlplus oapapp/OAPAPP@ccb_oap << !
select table_name||','||column_name||','||data_type||','||data_length from user_tab_columns where table_name = '$tbl_name'; 
!  这一句改为
sqlplus oapapp/OAPAPP@ccb_oap << !
select table_name||','||column_name||','||data_type||','||data_length from user_tab_columns where table_name = '$tbl_name'; 
! |grep $1
全部回答
  • 1楼网友:撞了怀
  • 2021-01-28 12:26
比面shell脚本文件:#===========test.sh! /bin/shecho_line(){ echo date echo "wellcome to shell func!"}echo_hello(){ echo "hello world!"}#======================shell调用两函数啊我用【./test.sh echo_hello】却没输我已经给test.sh加执行权限 请问envsetup.sh边 function gettop() { local topfile=build/core/envsetup.mk if [ -n "$top" -a -f "$top/$topfile" ] ; then echo $top else if [ -f $topfile ] ; then # the following circumlocution (repeated below as well) ensures # that we record the true directory name and not one that is # faked up with symlink names. pwd= /bin/pwd fi }并没返值 调用何获取参数 t=$(gettop) 实际参数谢谢
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯