如何将文件制作成shell脚本并运行它?

如何将文件制作成shell脚本并运行它?,shell,Shell,我创建了以下文件: tinymce_compressor.sh $chmod +x tinymce_compressor.sh $ tinymce_compressor -bash: tinymce_compressor: command not found 如何在终端中运行此shell脚本 以下是完整的脚本: #!/bin/sh # Tinymce compressor shell script # # This program is free software; you can redis

我创建了以下文件:

tinymce_compressor.sh
$chmod +x tinymce_compressor.sh
$ tinymce_compressor
-bash: tinymce_compressor: command not found
如何在终端中运行此shell脚本

以下是完整的脚本:

#!/bin/sh
# Tinymce compressor shell script
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
# 
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#        
# (C) Copyright 2010 Gabor Vitez
#
#
# Concatenates the tinymce components into a single static file
# Can be used with any web server which can serve static files
# Note you have to re-run this script every time you upgrade tinymce, 
# or change the required modules
#
# Usage: upon every invocation, the scipt will create a new 
# "tinymceappended.js" file, which contains the requested components
#
# In your html pages you have to change 
#
# <script type="text/javascript" src="<your installation path>/tiny_mce/tiny_mce.js"></script>
#
# to
#
# <script type="text/javascript" src="<your compressed tinymce url>/tinymceappended.js"> </script>
#


#config section
#where does tinymce live in the filesystem?
BASE="/Users/xxxx/Sites/cline/public/javascripts/tiny_mce/"
#under which URLs do the original tinymce components show up?
URLBASE="/tinymce"
#just as in the javascript config section
THEMES="advanced"
PLUGINS="safari spellchecker pagebreak style layer save advhr advimage advlink emotions iespell inlinepopups insertdatetime preview media searchreplace contextmenu paste directionality fullscreen noneditable visualchars nonbreaking xhtmlxtras"
LANGUAGES="en"
#end config section

(
LOADED=""
cd $BASE || exit 1
#cat tiny_mce.js
sed "s/tinymce._init();/tinymce.baseURL='\/tinymce';tinymce._init();/"<tiny_mce.js
#echo "tinyMCE_GZ.start();"
#cat tiny_mce_popup.js && LOADED="$LOADED $URLBASE/tiny_mce_popup.js"
for lang in $LANGUAGES
        do
                cat langs/$lang.js && LOADED="$LOADED $URLBASE/langs/$lang.js"
        done
for theme in $THEMES
        do
                cat themes/$theme/editor_template.js && LOADED="$LOADED $URLBASE/themes/$theme/editor_template.js"
                for lang in $LANGUAGES
                        do
                                cat themes/$theme/langs/$lang.js && LOADED="$LOADED $URLBASE/themes/$theme/langs/$lang.js"
                        done

        done

for plugin in $PLUGINS
        do
                cat plugins/$plugin/editor_plugin.js && LOADED="$LOADED $URLBASE/plugins/$plugin/editor_plugin.js"
                for lang in $LANGUAGES
                        do
                                cat  plugins/$plugin/langs/$lang.js && LOADED="$LOADED $URLBASE/plugins/$plugin/langs/$lang.js"
                        done

        done
echo
#echo $LOADED >&2
for i in $LOADED
        do
                echo "tinymce.ScriptLoader.markDone(tinyMCE.baseURI.toAbsolute(\"$i\"));"
        done
#echo "tinyMCE_GZ.end();"
) >tinymceappended.js
#/垃圾箱/垃圾箱
#Tinymce压缩程序外壳脚本
#
#这个程序是自由软件;您可以重新分发和/或修改它
#它是根据GNU通用公共许可证的条款发布的
自由软件基金会;许可证的第2版。
# 
#
#这个节目的发布是希望它会有用,
#但无任何保证;甚至没有任何关于
#适销性或适合某一特定目的。见
#有关更多详细信息,请参阅GNU通用公共许可证。
#        
#(C)版权所有2010 Gabor Vitez
#
#
#将tinymce组件连接到单个静态文件中
#可以与任何可以提供静态文件的web服务器一起使用
#注意:每次升级tinymce时都必须重新运行此脚本,
#或更改所需的模块
#
#用法:每次调用时,scipt都会创建一个新的
#“tinymceappended.js”文件,其中包含请求的组件
#
#在html页面中,您必须进行更改
#
# 
#
#到
#
#  
#
#配置部分
#tinymce在文件系统中的位置?
BASE=“/Users/xxxx/Sites/cline/public/javascripts/tiny_mce/”
#原始tinymce组件显示在哪些URL下?
URLBASE=“/tinymce”
#就像javascript配置部分一样
主题=“高级”
PLUGINS=“safari spellchecker pagebreak样式层保存advhr advimage advlink情绪iespell inlinepopups insertdatetime预览媒体搜索替换上下文菜单粘贴方向性全屏不可编辑可视框不可中断xhtmlxtras”
语言=“en”
#结束配置部分
(
LOADED=“”
cd$BASE | |出口1
#cat tiny_mce.js
sed“s/tinymce.\u init();/tinymce.baseURL='\/tinymce';tinymce.\u init();/”&2
因为我装了美元
做
echo“tinymce.ScriptLoader.markDone(tinymce.baseURI.toAbsolute(\“$i\”);”
完成
#echo“tinyMCE_GZ.end();”
)>tinymceappended.js

谢谢

默认情况下,当前目录不在路径上;您需要指定脚本位于当前文件夹中(
):


默认情况下,当前目录不在路径上;您需要指定脚本位于当前文件夹中(
):


脚本位于当前目录中,但默认情况下不在路径中(shell使用该路径来尝试并查找要运行的命令)。所以

./tinymce_compressor.sh

我们应该做到这一点。有关命令搜索路径的详细信息,以及在路径中包含当前目录(也称“.”)可能不是一个好主意的原因,请参阅Unix常见问题列表中的“”。

脚本位于当前目录中,但默认情况下不在路径中(shell使用该路径来尝试查找要运行的命令)。所以

./tinymce_compressor.sh

我们应该做到这一点。有关命令搜索路径的详细信息,以及为什么在路径中包含当前目录(又称“.”)可能不是一个好主意,请参阅Unix常见问题列表中的“”。

如果您已经找到了,请拨打

$ ./tinymce_compressor.sh

您似乎来自Windows,在Windows中可以不带扩展名地调用可执行文件,并且当前目录始终位于
路径中

只要调用

$ ./tinymce_compressor.sh

您似乎来自Windows,在Windows中可以不使用扩展名调用可执行文件,并且当前目录始终位于
路径中

可能。/tinymce\u compressor.sh?但我一点也不确定……我对这是否是一个话题持怀疑态度;它适合,也许可以。/tinymce_compressor.sh?但我一点也不确定……我对这是否是一个话题持怀疑态度;它很合身,也许