You are not logged in.

#1 2010-03-30 08:50:58

YZMSQ
Member
From: Hangzhou,Zhejiang,China
Registered: 2009-11-18
Posts: 97

[SOLVED]I'd like to remove them but...

Hello,guys:
I just wrote a tiny script to remove the packages that were installed as dependencies but are no longer
required by any installed package.However, it always complained to me for some reasons:
my script:

#!/bin/bash
 pkg=$(pacman -Qdt|gawk '{ printf "%s ", $1; }') 
 test -n $pkg
 if [ $? = 0 ];then
      echo I will remove $pkg
      sudo pacman -Rs $pkg
 else 
       echo DO NOT NEED TO REMOVE ANYTHING!
 fi

and it complained:

./abs.sh: line 3: test: git: binary operator expected
DO NOT NEED TO REMOVE ANYTHING!

P.S.:

[justin@YZMSQ Desktop]$ pacman -Qdt
git 1.7.0.3-1
phonon 4.4.0-1

What's wrong with my code?I need your help,please.:D

Last edited by YZMSQ (2010-03-30 09:42:47)


This is the way the world ends
Not with a bang but a whimper
                            -------T·S·Eliot

Offline

#2 2010-03-30 09:09:00

r6
Member
From: Melbourne
Registered: 2008-07-02
Posts: 156

Re: [SOLVED]I'd like to remove them but...

Hello

Try this

pacman -Rsn $(pacman -Qdtq)

Offline

#3 2010-03-30 09:10:06

FOODy
Member
From: Germany
Registered: 2009-10-07
Posts: 5

Re: [SOLVED]I'd like to remove them but...

Put the $pkg into "" so it would expand to a string. (  test -n "$pkg" )

At the moment the shell thinks of your line as this: ( pkg="git 1.7.0.3-1 phonon 4.4.0-1" )

test -n git 1.7.0.3-1 phonon 4.4.0-1

( 3 extra arguments: "1.7.0.3-1", "phonon" and "4.4.0-1" )

With the little change above it would be like:

test -n "git 1.7.0.3-1 phonon 4.4.0-1"

Offline

#4 2010-03-30 09:32:55

YZMSQ
Member
From: Hangzhou,Zhejiang,China
Registered: 2009-11-18
Posts: 97

Re: [SOLVED]I'd like to remove them but...

Thank you for your help,I've learned much from your words.
Thanks.:)


This is the way the world ends
Not with a bang but a whimper
                            -------T·S·Eliot

Offline

#5 2010-03-30 09:39:40

YZMSQ
Member
From: Hangzhou,Zhejiang,China
Registered: 2009-11-18
Posts: 97

Re: [SOLVED]I'd like to remove them but...

r6 wrote:

Hello

Try this

pacman -Rsn $(pacman -Qdtq)

Thank you for your help.
Well,How could you get "pacman -Rsn"and "pacman -Qdtq"?I just know "-Rs" and "-Qdt"~~~:)
P.S.:I just got them in man,hoho.Thanks.:)

Last edited by YZMSQ (2010-03-30 09:42:10)


This is the way the world ends
Not with a bang but a whimper
                            -------T·S·Eliot

Offline

#6 2010-03-30 12:26:03

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: [SOLVED]I'd like to remove them but...

As a sidenote, pacman -Rsn $(pacman -Qdtq) should be used with extreme care, because -Qdt can often include packages that you do want to keep.
eg on my box it includes xorg-utils, cmake, cvs, subversion, pyparsing, docutils and more that I use more or less daily.


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#7 2010-03-30 14:16:06

JohannesSM64
Member
From: Norway
Registered: 2009-10-11
Posts: 623
Website

Re: [SOLVED]I'd like to remove them but...

Therefore, use zsh and press tab after $(pacman -Qdtq) to expand it, then remove those you want to keep from the line.

Offline

Board footer

Powered by FluxBB