Article View: es.comp.os.linux.programacion
Article #10386Re: Mas dudas sobre bash script :P
From: Claudio S.
Date: Sun, 03 Mar 2002 15:21
Date: Sun, 03 Mar 2002 15:21
25 lines
1835 bytes
1835 bytes
El 1 Mar 2002 13:34:27 GMT, J.A. Gutierrez <spd@daphne.cps.unizar.es> escribi�:
> Angel Lis <a.lis@bussitel.es> wrote:
>:> Angel Lis wrote:
>:>
>:>> como ConyXX consigo saber el numero de caracteres de una varible??
>:>> en el man pone que ${#var}, pero no tira :~(, estoy utilizando un bucle
>:>> con el cut, pero a ver si alguien sabe como facerlo. Venga talugo.
>
> ${#var} deberia funcionar en cualquier sh
>
>: #echo -n $var | wc -c -
>
> pero dependes de una implementacion particular de "echo"
>
> Alternativa:
> expr "$A" : '.*'
O tambi�n:
expr length "$A"
echo "$var" | awk '{print length}'
Las comillas son importantes en la segunda si la cadena puede tener
varios espacios seguidos.
Un saludo.
--claudio--
Technical Details
Message-ID:
<82ft5a.i61.ln@127.0.0.1>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news-x2.support.nl!amsnews01.chello.com!newsfeed.freenet.de!fu-berlin.de!uni-berlin.de!139.red-80-59-173.pooles.rima-tde.NET!not-for-mailReferences:
<snKf8.40394$Q5.584806@telenews.teleline.es> <PFKf8.40735$Q5.588143@telenews.teleline.es> <MHKf8.40773$Q5.587795@telenews.teleline.es> <a5o013$j61$1@news.unizar.es>Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: f86c8,93a36f64772b96d6 X-Google-Attributes: gidf86c8,public X-Google-ArrivalTime: 2002-03-03 08:05:52 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news-x2.support.nl!amsnews01.chello.com!newsfeed.freenet.de!fu-berlin.de!uni-berlin.de!139.red-80-59-173.pooles.rima-tde.NET!not-for-mail From: "Claudio S." <claudio@dev.null.org> Newsgroups: es.comp.os.linux.programacion Subject: Re: Mas dudas sobre bash script :P Date: Sun, 3 Mar 2002 16:21:44 +0100 Lines: 26 Message-ID: <82ft5a.i61.ln@127.0.0.1> References: <snKf8.40394$Q5.584806@telenews.teleline.es> <PFKf8.40735$Q5.588143@telenews.teleline.es> <MHKf8.40773$Q5.587795@telenews.teleline.es> <a5o013$j61$1@news.unizar.es> NNTP-Posting-Host: 139.red-80-59-173.pooles.rima-tde.net (80.59.173.139) Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: fu-berlin.de 1015171550 10398773 80.59.173.139 (16 [130458]) X-Orig-Path: 127.0.0.1!nobody User-Agent: slrn/0.9.7.3 (Linux)