[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: String handling i bash - SOLVED



On Fri, 18 Sep 2009 15:22:59 -0200, Frank wrote:

> Undlad at bruge basename da den skal starte en ny proces.

Det kan være en ulempe hvis hans script kører det rigtigt, rigtigt mange
gange.
 
> Hans forslag, newdir=${latest##*/}, er klart den bedste måde at håndtere det på.

Men kræver en speciel shell der kan den syntaks, dvs. bash.

[...] 
> Man kan også lave andre smarte ting med variabler.
 
> F.eks. dette i et script:
 
> Comment="Dette er en kommentar!"
> echo "${Comment// /_}"
 
> giver dette resultat: Dette_er_en_kommentar!

Ikke i alle shells, i f.eks. dash, der følger POSIX specifikationen og
vejer væsentligt mindre end bash (ca. 1/8), får du:

  $ Comment="Dette er en kommentar!"
  $ echo "${Comment// /_}"
  dash: Bad substitution
  $ 


  Mvh.

   Adam

-- 
 "Super heroes wear snow pants?"                              Adam Sjøgren
 "When there's snow out, they do!"                       sslug@sslug


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2009-10-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] *