2022年1月20日星期四

shell command readlink

$ readlink  -f ./script/test.sh
/home/user/script/test.sh

#check file or directory exists.
readlink -v $dir/env
readlink: ./script/env: No such file or directory

#no check file or directory exists.
$ readlink -m $dir/env
/home/eru/im-convoy-master/script/env

$ readlink --help
Usage: readlink [OPTION]... FILE...
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
  -e, --canonicalize-existing   canonicalize by following every symlink in
                                every component of the given name recursively,
                                all components must exist
  -m, --canonicalize-missing    canonicalize by following every symlink in
                                every component of the given name recursively,
                                without requirements on components existence
  -n, --no-newline              do not output the trailing delimiter
  -q, --quiet,
  -s, --silent                  suppress most error messages (on by default)
  -v, --verbose                 report error messages
  -z, --zero                    end each output line with NUL, not newline
      --help     display this help and exit
      --version  output version information and exit


没有评论: