Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

I need a little help with bash or sh [solved]

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
4 posts • Page 1 of 1
Author
Message
re4ps2
n00b
n00b
Posts: 17
Joined: Sat Jan 30, 2010 3:10 pm

I need a little help with bash or sh [solved]

  • Quote

Post by re4ps2 » Sat Jan 30, 2010 3:22 pm

Code: Select all

if $1 | grep zip; then unzip; fi
if $1 | grep rar; then "unrar e"; fi
The code does not work. Please help me fix it. Thanks.
Last edited by re4ps2 on Sat Feb 20, 2010 7:28 pm, edited 1 time in total.
Top
Genone
Retired Dev
Retired Dev
User avatar
Posts: 9657
Joined: Fri Mar 14, 2003 6:02 pm
Location: beyond the rim

  • Quote

Post by Genone » Sat Jan 30, 2010 3:56 pm

Would help if you'd say what exactly you're trying to do ...
Top
Sadako
Advocate
Advocate
User avatar
Posts: 3792
Joined: Thu Aug 05, 2004 5:50 pm
Location: sleeping in the bathtub
Contact:
Contact Sadako
Website

  • Quote

Post by Sadako » Sat Jan 30, 2010 3:56 pm

You might wanna explain exactly what it is you're trying to do first (we're not mindreaders you know :P), but at a guess;

Code: Select all

case "$1" in
    *.zip )
        unzip "$1" ;;
    *.rar )
        unrar e "$1" ;;
esac
You might wanna take a look at the "unfoo" script, which does exactly this, and for other file types too.

It's in portage, if you use gentoo...
"You have to invite me in"
Top
Veldrin
Veteran
Veteran
User avatar
Posts: 1945
Joined: Tue Jul 27, 2004 5:47 pm
Location: Zurich, Switzerland

  • Quote

Post by Veldrin » Sat Jan 30, 2010 3:59 pm

A quick google turned up this....

basically this make it work...

Code: Select all

if [[ $1 == *zip ]]
  then unzip $1
elif [[ $1 == *rar ]]
  then rar e $1
fi
just my .02$
V.
Top
Post Reply

4 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Authors
Gentoo is a trademark of the Gentoo Foundation, Inc. and of Förderverein Gentoo e.V.
The contents of this document, unless otherwise expressly stated, are licensed under the CC-BY-SA-4.0 license.
The Gentoo Name and Logo Usage Guidelines apply.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy