🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #1164

Re: Capturar ultimo caracter de una linea

#1164
From: Pascal Bourguignon
Date: Tue, 07 Mar 2006 16:29
37 lines
2495 bytes
speeter <speeter@terra.es> writes:

> Pascal Bourguignon wrote:
>
>> speeter <speeter@terra.es> writes:
>> 
>>>Estoy haciendo un script en bash y necesito capturar el ultimo
>>>caracter de una linea, en una variable.
>> linea="abcdef"
>> ultimo_caracter="${linea:$((${#linea}-1))}"
>> printf "%s\n" "$ultimo_caracter"
>> 
> Gracias Pascal, funciona ok.
>
> Donde (pagina man, manual, etc) puedo consultar la sintaxis de lo que
> me pones?

Por supuesto, esta en:
   man bash


    [...]
       ${parameter:offset:length}
              Substring Expansion.  Expands  to  up  to  length  characters  of
              parameter  starting  at  the  character  specified by offset.  If
              length is omitted, expands to the substring of parameter starting
              at  the  character  specified  by  offset.  length and offset are
    [...]


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
Technical Details
Message-ID: <873bhurzfb.fsf@thalassa.informatimago.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
References: <xxhPf.741242$kp.5245523@telenews.teleline.es> <87fylus1nz.fsf@thalassa.informatimago.com> <b6iPf.741424$kp.5246857@telenews.teleline.es>

Show Full Headers
Complete Article Headers
X-Google-Thread: f86c8,7b333a468341e8d8
X-Google-Attributes: gidf86c8,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: Pascal Bourguignon <usenet@informatimago.com>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Capturar ultimo caracter de una linea
Date: Tue, 07 Mar 2006 17:29:28 +0100
Organization: Informatimago
Lines: 37
Message-ID: <873bhurzfb.fsf@thalassa.informatimago.com>
References: <xxhPf.741242$kp.5245523@telenews.teleline.es> <87fylus1nz.fsf@thalassa.informatimago.com> <b6iPf.741424$kp.5246857@telenews.teleline.es>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: individual.net EJ9mUUmq8DHoPpMo78nZnwRKrmiXTvlbVywE5H4f+cyPciNa5b
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA
      oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9
      033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac
      l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR
      mV+hO/VvFAAAAABJRU5ErkJggg==
X-Accept-Language:         fr, es, en
X-Disabled: X-No-Archive: no
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)
Cancel-Lock: sha1:sj0HjYVICKTxOiFN7i7wBcE1E+8=