shell 判断文件是否是可执行文件
测试变量指定的文件是否存在且是可执行文件。如果存在且是可执行文件,则执行该文件,否则通过chmod命令赋予该文件可执行权限。 //test.sh
#!/bin/bash
echo "enter the name:"
read filename
if test -x $filename ; then
./$filename
else
sudo chmod +x $filename
ls -l $filename
fi
//sss.sh
#!/bin/bash echo "What is your favourite OS?"
select var in "Linux" "Gnu Hurd" "Free BSD" "Other"; do
break;
done
echo "You have selected $var"
运行
./test.sh
输出:
enter the name:
sss.sh
-rwxrwxr-x f f Dec : sss.sh
再次运行
./test.sh
输出
enter the name:
sss.sh
What is your favourite OS?
1) Linux
2) Gnu Hurd
3) Free BSD
4) Other
#? 1
You have selected Linux
shell 判断文件是否是可执行文件的更多相关文章
- shell判断文件是否存在
转自:http://www.cnblogs.com/sunyubo/archive/2011/10/17/2282047.html 1. shell判断文件,目录是否存在或者具有权限 2. #!/bi ...
- Linux shell判断文件和文件夹是否存在
shell判断文件,目录是否存在或者具有权限 #!/bin/sh myPath="/var/log/httpd/" myFile="/var /log/httpd/acc ...
- shell 判断文件、目录是否存在
shell判断文件是否存在 1. shell判断文件,目录是否存在或者具有权限 2. #!/bin/sh 3. 4. myPath="/var/log/httpd/" 5. m ...
- Shell 判断文件或文件夹是否存在
#shell判断文件夹是否存在 #如果文件夹不存在,创建文件夹 if [ ! -d "/myfolder" ]; then mkdir /myfolder fi #shell判断文 ...
- [转] Linux shell判断文件和文件夹是否存在
shell判断文件,目录是否存在或者具有权限 #!/bin/sh myPath="/var/log/httpd/" myFile="/var /log/httpd/acc ...
- shell判断文件夹是否存在
#shell判断文件夹是否存在 #如果文件夹不存在,创建文件夹 if [ ! -d "/myfolder" ]; then mkdir /myfolder fi #shell判断文 ...
- shell判断文件类型和权限
shell 判断文件类型. -d 文件 判断该文件是否存在,并且是否为目录(是目录为真) -e文件 判断该文件是否存在(存在为真) -f文件 判断该文件是否存在,并且是否为文件(是普通文件为真) - ...
- shell判断文件是否存在[转]
原文出处: http://canofy.iteye.com/blog/252289 shell判断文件,目录是否存在或者具有权限 #!/bin/sh myPath="/var/log/htt ...
- shell判断文件,目录是否存在或者具有权限
shell判断文件,目录是否存在或者具有权限 #!/bin/sh myPath="/var/log/httpd/" myFile="/var /log/httpd/ ...
随机推荐
- AndroidStudio build.gradle 报错
Android Studio. I'm getting this kind of error during application run. Error:Execution failed for ta ...
- 用 chown 和 chmod 修改目录所属用户及权限
1.修改 tmp 目录所属用户为 root,用户组为 root chown -R root:root /tmp12.修改 tmp 目录为可写权限 chmod -R 777 /tmp
- HDU1530 Maximum Clique dp
正解:dp 解题报告: 这儿是传送门 又是个神仙题趴QAQ 这题就直接说解法辣?主要是思想比较难,真要说有什么不懂的知识点嘛也没有,所以也就没什么好另外先提一下的知识点QAQ 首先取反,就变成了求最大 ...
- CSRF攻击详解(转)
原文:http://www.django-china.cn/topic/580/ 一.CSRF是什么? CSRF(Cross-site request forgery),中文名称:跨站请求伪造,也被称 ...
- 省市县三级联动的SQL
完整版见https://jadyer.github.io/ 首先是建表语句 CREATE TABLE `t_address_province` ( `id` INT AUTO_INCREMENT PR ...
- mysql实现开窗函数、Mysql实现分析函数
关键字:mysql实现开窗函数.Mysql实现分析函数.利用变量实现窗口函数 注意,变量是从左到右顺序执行的 --测试数据 CREATE TABLE `tem` ( `id` ) NOT NULL A ...
- [Axiom 3D]3.SceneManager场景管理器
首先看看Axiom.Core命名空间下public abstract class SceneManager : DisposableObject A SceneManager organizes th ...
- 20165324_mybash
20165324_mybash 实验要求 实验要求: 使用fork,exec,wait实现mybash 写出伪代码,产品代码和测试代码 发表知识理解,实现过程和问题解决的博客(包含代码托管链接) 背景 ...
- VirtualXposed查看手机端网页及调试
参考博客: https://sspai.com/post/44447 以下是实际动手操作步骤: 一 打开手机开发者模式 二 允许USB调试 三 安装 VirtualXposed_1.apk ...
- "字节跳动杯"2018中国大学生程序设计竞赛-女生专场 Solution
A - 口算训练 题意:询问 $[L, R]$区间内 的所有数的乘积是否是D的倍数 思路:考虑分解质因数 显然,一个数$x > \sqrt{x} 的质因子只有一个$ 那么我们考虑将小于$\sqr ...