#!/usr/bin/bash

dir_old=$(pwd)
absolute_script_path=$(cd $(dirname $0) && pwd)
relative_script_path=$(dirname $0)
wrong_absolute_script_path=$dir_old/$relative_script_path

echo "Current PATH: $dir_old"
echo "absolute_script_path is: $absolute_script_path"
echo "relative_script_path is: $relative_script_path"
echo "This path might be wrong: $wrong_absolute_script_path"

# Fail if use absolute path to invoke script
cd $wrong_absolute_script_path && pwd

Get Script Path in Shell的更多相关文章

  1. shell script 学习笔记-----shell变量

    1.在赋值语句name=value中不能存在空格,例如:name = value这样的形式会被认为是三个变量,因为本质上来说,脚本的内容就是传给shell程序的变量,而变量之间是通过空格区分的.如果想 ...

  2. Flask script 内的Shell 类 使用

    1.集成Python shell 每次自动shell会话都要导入数据库实例和模型,很烦人.为了避免一直重复导入,我们可以做些配置让Flask-Script的Shell命令自动导入特定的对象.若想把对象 ...

  3. bash shell学习-shell script基础 (笔记)

    A chain no stronger than its weakest link. "一着不慎,满盘皆输" 参考资料:鸟哥的Linux私房菜 基础学习篇(第三版)  Linux ...

  4. shell script 入门 笔记

    shell script 入门 在 shell script 注意必须使用完全相同写在下面: 1.  指令的运行是从上而下.从左而右的分析与运行: 2.  指令的运行就如同第五章内提到的: 指令.选项 ...

  5. 菜鸟教程之学习Shell script笔记(上)

    菜鸟教程之学习Shell script笔记 以下内容是,学习菜鸟shell教程整理的笔记 菜鸟教程之shell教程:http://www.runoob.com/linux/linux-shell.ht ...

  6. 第13章 学习shell script

    由于博客园中dollar符号有别的意义,所以文中的dollar符号使用¥表示 第一个script [root@localhost script]# cat -n sh01.sh #!/bin/bash ...

  7. Shell Script Basics

    https://developer.apple.com/library/mac/documentation/OpenSource/Conceptual/ShellScripting/shell_scr ...

  8. 菜鸟的《Linux程序设计》学习—shell script

    1. 认识shell script shell script是利用shell的功能缩写的一个"程序",这个程序是使用纯文本文件,将一些shell的语法与命令(含外部命令)写在里面, ...

  9. shell 编程 && bash 简介(shell 变量、shell操作环境、数据流重导向、管线命令、shell script)

    如何学习一门编程语言 数据类型 运算符 关键字 1 认识BASH 这个shell linux是操作系统核心,用户通过shell与核心进行沟通,达到我们想要的目的.硬件.核心.用户之间的关系: 原理:所 ...

随机推荐

  1. Scala相关

    vim conf for scala: http://stackoverflow.com/questions/3626203/text-editor-for-scala http://fengshen ...

  2. HDU2586How far away ?

    http://acm.hdu.edu.cn/showproblem.php?pid=2586 How far away ? Time Limit: 2000/1000 MS (Java/Others) ...

  3. $smarty获取变量get,post等用法

    {$smarty}保留变量不需要从PHP脚本中分配,是可以在模板中直接访问的数组类型变量,通常被用于访问一些特殊的模板变量.例如,直接在模板中访问页面请求变量.获取访问模板时的时间邮戳.直接访问PHP ...

  4. Win10 + Nginx 1.10 + PHP 7 + Redis 配置方法

    软件包版本 软件 版本 - 链接 - Nginx nginx-x32-1.10.2.zip 下载 PHP php-7.0.12-nts-Win32-VC14-x64 下载 Redis php_redi ...

  5. vue.js存储--localStorage

    //list例子:绑定从localStorage中读取的数据,动态添加list并监听将数据变化存储在localStorage中,绑定点击事件改变样式, 页面 data数据: input_name:'' ...

  6. lseek函数

    所有打开的文件都有一个当前文件偏移量(current file offset),以下简称为 cfo.cfo 通常是一个非负整数,用于表明文件开始处到文件当前位置的字节数.读写操作通常开始于 cfo,并 ...

  7. FAQ

    1.Baudrare and the speed of Byte. 2. Linux FS and Flash store. 3. SW's Coupling. 4. Protocol and Pro ...

  8. this 的值到底是什么?

    你可能遇到过这样的 JS 面试题: var obj = { foo: function(){ console.log(this) } } var bar = obj.foo obj.foo() // ...

  9. (转载)Linux如何编译安装源码包软件

    一.什么是源码包软件: 顾名思义,源码包就是源代码的可见的软件包,基于Linux和BSD系统的软件最常见:在国内源可见的软件几乎绝迹:大多开源软件都是国外出品:在国内较为出名的开源软件有fcitx;l ...

  10. Nodejs的安装及配置

    1.从Nodejs官网下载安装包,进行安装,是否安装成功,可以从cmd npm去检查,出现如下界面,就表示安装成功 2.打开Webstorm进行配置,(如果安装前打开webstorm了,需要重启web ...