Не сте регистриран! Регистрирайте се БЕЗПЛАТНО, за да използвате услугите на сайта!

 whichbin - show links and path to executable
Автор  Ext2 (08.11.2004 23:54) съобщение до автора
Погледнат  996 пъти добави към любими
Оценка добави коментар
Гласове  -- изпрати на приятел
Коментари  (0) абонирай се за Shell
     
Ext2
     
 

#! /bin/bash
  1. ################################################

       NAME_="whichbin"
    PURPOSE_="show links and path to executable"
   SYNOPSIS_="$NAME_ [-hl] <executable> [executable...]"
   REQUIRES_="standard GNU commands"
    VERSION_="1.0"
       DATE_="2004-07-11; last update: 2004-07-11"
     AUTHOR_="Dawid Michalczyk <dm@eonworks.com>;"
        URL_="www.comp.eonworks.com"
   CATEGORY_="sys"
   PLATFORM_="Linux"
      SHELL_="bash"
 DISTRIBUTE_="yes"

  1. #################################################
  2. This program is distributed under the terms of the GNU General Public License

usage () {

echo >&2 "$NAME_ $VERSION_ - $PURPOSE_
Usage: $SYNOPSIS_
Requires: $REQUIRES_
Options:
     -h, usage and options (this help)
     -l, see this script"
    exit 2
}

  1. args check
[ $# -eq 0 ] && { echo >&2 missing argument, type $NAME_ -h for help; exit 2; }

follow_link() {

    file=$(which $1)
    [ $? != 0 ] && { echo $1 not an executable ; exit 2; }
    if [ -L $file ];then
        echo symlink $file
        cd $(dirname $file)
        follow_link $(set -- $(ls -l $1); shift 10; echo $1)
    else
        ls -l $file
    fi

}

  1. arg handling and main execution
case $1 in

    -h) usage ;;
    -l) more $0; exit 2 ;;
     *) # main execution

        for a in $@;do
            follow_link $a
        done ;;

esac



Ключови думи: shell transfer shell script bin bash executable path terms




 1 посетител чете този скрипт (0 потребители и 1 гост)  
Активни потребители: ---
   
  

Еmail  
 

 

 
  • Интересно от Софтуер
 
  • Интересно от myLINKS
 
 
 
 



IT-PLACE.NET © 2004 - 2008