[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] Fildatoer og strenge i bash



On 3/16/06, Jens Bang <sslug@sslug> wrote:
> Jeg er i gang med et bash-script, hvor jeg skal have trukket årstallet ud af
> en fildato, og efterfølgende bruge det årstal i en streng jeg giver videre
> til et andet program.
>
> Umiddelbart ser det ud til at jeg kan bruge
>         stat --format=%y FILNAVN
> eller
>         stat --format=%z FILNAVN
> til at få dato for sidste ændring (hvad er egentlig forakellen på de to?), men
> hvordan får jeg puttet datoen ind i en streng, og efterfølgende kortet
> strengen af og sendt den videre?
>

sslug@sslug ~ $ let a=`stat --format=%y <filnavn> | cut -d '-' -f 1`
sslug@sslug ~ $ echo $a
2006

let tildeler en variabel en værdi, cut beskærer, -d '-' splitter den
op efter bindestrejer, -f 1 tager det første felt

--
Bjørn Hartfelt//bjuhn_com//otaku-hacker-ninja-pirate-dictator


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

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