shell 学习笔记

#!/bin/bash

# shell 学习笔记

#Create a temporary file or directory, safely, and print its name.
# -d, --directory     create a directory, not a file
export TMP_DIR='mktemp -d'

# $? is used for checking return result





readlink :

readlink - print value of a symbolic link or canonical file name

       -f, --canonicalize
              canonicalize  by  following every symlink in every component of the given name recursively; all but the
              last component must exist

一般使用 readlink -f .

-f 使用和不使用的区别是 -f 会 递归找最终的链接,不加 -f 就直接一级。

$ mkdir -p ~/wrwork/bash

$ cd ~/wrwork/bash

$ ln -s ~/Downloads test

$ ln -s test test1

$ readlink -f test1

/home/chenqiang/Downloads

$ readlink test1

test



       which - locate a command

SYNOPSIS
       which [-a] filename ...

DESCRIPTION
       which  returns  the  pathnames of the files (or links) which would be executed in the current environment, had
       its arguments been given as commands in a strictly POSIX-conformant shell.  It does this by searching the PATH
       for executable files matching the names of the arguments. It does not follow symbolic links.

chenqiang@qiang:~/wrwork/bash$ which git >/dev/null
chenqiang@qiang:~/wrwork/bash$ echo $?






































  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值