[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

RE: [PROGRAMMERING] bash: element er i liste



> Hej
> 
> Er det muligt i bash at checke om et element er i en liste 
> (ala pythons 
> "in")?
> 
> Det jeg rent praktisk er ved at lave er et check for om input 
> ($1, som 
> er et filnavn) har en extension svarende til en i en liste (som jeg 
> bestemmer).
> 
> -- 
> peace, love & harmony
> Atte
> 
> På æsken stod der "use Windows XP or better", så jeg 
> installerede Linux...
> 

Prøv med denne case:

filename=$1
extension=${filename##*.} #tager altid extension efter sidste punktum uanset hvor mange der findes i filnavn.

case $extension in
  tiff) cmd1;;
  png)  cmd2;;
  jpeg  cmd3;;
esac


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2008-04-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *