which package a file belongs to

frmas frmas at free.fr
Sun Jan 18 11:58:55 UTC 2009


Matthew Flaschen a écrit :
> Nils Kassube wrote:
>> frmas wrote:
>>> I've tried to optimize that, but I failed. I don't know how to get rid
>>> of those little ":" at the end of the name. This is my command line :
>>>  dpkg -S /usr/bin/nedit | dpkg -l `awk '{print $1}'`
>>> but awk returns "nedit:" ;-(
>>> I do not know how to remove those ":".... Francois
>> How about this?
>>
>> dpkg -S /usr/bin/nedit|dpkg -l $(cut -f1 -d':')
> 
> Doesn't work.  But:
> 
>   dpkg -l `dpkg -S /usr/bin/nedit|cut -f1 -d':'`

Thank you to all of you. Time to share my work. From your posts, I wrote
that litte script I placed in my /usr/local/bin directory. That way I
can run it against a file without all the stuff to type (and remember)
each time :-)

This is it. Save it, chmod to 755 and voila. I would be pleased if some
of you could improve it.

>----------------------cut here --------------------------------
#!/bin/bash

startScript() {
case $1 in
  --{$1} | -{$1})
    TYPE="itsok"
    ;;
  --help | -help | -H | --H | -h | --h)
    echo ""
    echo "Usage: \"$0 --file_searched\" - file_searched \
as to be replaced with the path and name file."
echo ""
    exit;;
  *)
esac

if [[ $1 = "" ]] ; then
  clear
  echo "*************Warning***Warning***Warning*************"
  echo "*                                                   *"
  echo "*  Run that script with a parameter as :            *"
  echo "*         \"paquet /usr/bin/nedit\"                   *"
  echo "*                                                   *"
  echo "***Warning*************Warning*************Warning***"
  exit 1
  else
  clear
  echo ""
  clear
  echo "."
  read -t 1
  clear
  echo ".."
  read -t 1
  clear
  echo "..."
fi
}

startScript $1

dpkg -l `dpkg -S $1|sed s/:.*//`

exit
>----------------------cut here --------------------------------




More information about the ubuntu-users mailing list