转载:对#!/bin/sh的认识
转载网址:http://blog.163.com/hashes@yeah/blog/static/16867631220101029847420/
对#!/bin/sh的认识
第一次学shell编程,看的文章中说shell程序必须以"#!/bin/sh"开始,也就认为是这样了,虽然知道在shell中以"#"开始的语句都是注释,但也从没认为"#!/bin/sh"也是注释,就像对C语言程序必须有main函数一样毫无怀疑。但前些时候又听说"#!/bin/sh"也是注释,可有可无,当时觉得真是一个失败,连基本的语法都分不清。前几天借了一本书,才真正认识了"#!/bin/sh"。shell编程是以"#"为注释,但对"#!/bin/sh"却不是。"#!/bin/sh"是对shell的声明,说明你所用的是那种类型的shell及其路径所在。(#! /bin/sh 是指此脚本使用/bin/sh来解释执行,#!是特殊的表示符,其后面跟的是解释此脚本的shell的路径)如果没有声明,则脚本将在默认的shell中执行,默认shell是由用户所在的系统定义为执行shell脚本的shell.如果脚本被编写为在Kornshell ksh中运行,而默认运行shell脚本的为C shell csh,则脚本在执行过程中很可能失败。所以建议大家就把"#!/bin/sh"当成C 语言的main函数一样,写shell必须有,以使shell程序更严密。
一个命令行结束用&
运行时首先要将文件的权限修改为可执行:chmod +x comdfile
然后要指定执行文件的路径,否则系统会认为执行文件在系统默认目录下。
假如可执行文件在当前的目录下,则:./comdfile ?
$bash是什么意思?
$表示系统提示符,$ 表示此用户为普通用户,超级用户的提示符是#,bash是shell的一种,是linux下最常用的一种shell,$bash的意思是执行一个子shell,此子shell为bash。
转载网址:http://blog.sina.com.cn/s/blog_6336857901019zyz.html
转载:对#!/bin/sh的认识的更多相关文章
- 交叉编译环境以及开发板上-/bin/sh: ./hello: not found 转载自 http://blankboy.72pines.com
交叉编译环境以及开发板上-/bin/sh: ./hello: not found 目标板是S3C2440.至于交叉编译环境的搭建就不多说了,网上很多教程. 搭建好了交叉编译环境后,第一件事就是传说中的 ...
- Linux中运行.sh脚本,异常/bin/sh^M: bad interpreter: No such file or directory。
在Linux中运行.sh脚本,异常/bin/sh^M: bad interpreter: No such file or directory. 分析:这是不同系统编码格式引起的:在windows系统中 ...
- [shell编程] sh脚本异常:/bin/sh^M:bad interpreter: No such file or directory
转载地址:http://www.cnblogs.com/pipelone/archive/2009/04/17/1437879.html 在Linux中执行.sh脚本,异常/bin/sh^M: bad ...
- #!/bin/sh简介
第一次学shell编程,看的文章中说shell程序必须以"#!/bin/sh"开始,也就认为是这样了,虽然知道在shell中以"#"开始的语句都是注释,但也从没 ...
- -bash: ./start.sh: /bin/sh^M: bad interpreter: No such file or directory 错误解决方案
问题描述:sh文件中,在win环境下,用WinSCP编辑,出现如下错误: -bash: ./start.sh: /bin/sh^M: bad interpreter: No such file or ...
- 解决:/bin/sh: 1: /home/**/custom_app.sh: Permission denied错误
出现如下错误,一般是执行权限不够. /bin/sh: : /home/custom_app.sh: Permission denied 解决方法是:cd 到此文件目录,对提示的文件赋予可执行权限或读写 ...
- bin/sh^M: bad interpreter: No such file or directory解决
问题:bin/sh^M: bad interpreter: No such file or directory 原因:.sh脚本在windows系统下用记事本文件编写的.不同系统的编码格式引起的. 解 ...
- sh脚本异常:/bin/sh^M:bad interpreter: No such file or directory
在Linux中执行.sh脚本,异常/bin/sh^M: bad interpreter: No such file or directory. 分析:这是不同系统编码格式引起的:在windows系统中 ...
- linux 报错 bash ‘/bin/sh: Syntax error: “(” unexpected
今天用make 编译 蹦到 bash ‘/bin/sh: Syntax error: “(” unexpected 和 /bin/sh: [[: not found 这种莫名奇妙的错误 原因是是lin ...
随机推荐
- 从客户端(xxxxxxxxxxxxxxxxxxxxxx)中检测到有潜在危险的 Request.Form 值。
在项目中用到了富文本编辑器,当将编辑器中的值从视图传递到控制器时,控制器就会向浏览器返回“从客户端(xxxxxxxxxxxxxxxxxxxxxx)中检测到有潜在危险的 Request.Form 值.” ...
- 健身计划_from85to75
第一天没什么好写的,这半年也没看什么书,就写写未来的规划好了. 当然是从最简单的健身计划开始写咯. 关键词:弹性 目标:减肥,上肢力量 时间:3-4次/周(Thur,Fri,Sat,Sun),1h-1 ...
- QuerryRunner Tools
package com.ydbg.gis.utils; import java.sql.SQLException; import java.util.List; import java.util.Ma ...
- ural 1180 Stone Game
http://acm.timus.ru/problem.aspx?space=1&num=1180 #include <cstdio> #include <cstring&g ...
- C#控制生成图片的大小
private void button1_Click(object sender, EventArgs e) { using (Bitmap bitmap = new Bitmap("d:\ ...
- atof
So given a string like "2.23" your function should return double 2.23. This might seem eas ...
- C语言#pragma预处理
在所有的预处理指令中,#pragma 指令可能是最复杂的了,它的作用是设定编译器的状态或者是指示编译器完成一些特定的动作.#pragma 指令对每个编译器给出了一个方法,在保持与C 和C ++语言完全 ...
- curl_easy_setopt-curl库的关键函数之一
函数原型:#include <curl/curl.h>CURLcodecurl_easy_setopt(CURL *handle, CURLoption option, parameter ...
- HDU-1047(DP-二进制状态压缩)
Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of h ...
- Day02_VI基本操作及C基础
2013年09月30日 星期一 09时37分03秒 回顾: 1. linux系统的知识背景 2. vi的使用 在正常模式下使用nyy可以把光标所在行开始的连续n行拷贝到剪贴板上去 在正 ...