Expansão de parâmetros no bash

Pegar parâmetro usando $1 $2 e $3 é fácil né?

Todo mundo já sabe!

E se você quiser pegar apenas os parâmetros do 3 pra frente?

${*:3}

Loko.

:)

refs

3.4.2 Special Parameters
The shell treats several parameters specially. These parameters may only be referenced; assignment to them is not allowed.

*
($*) Expands to the positional parameters, starting from one. When the expansion is not within double quotes, each positional parameter expands to a separate word. In contexts where it is performed, those words are subject to further word splitting and filename expansion. When the expansion occurs within double quotes, it expands to a single word with the value of each parameter separated by the first character of the IFS special variable. That is, "$*" is equivalent to "$1c$2c…", where c is the first character of the value of the IFS variable. If IFS is unset, the parameters are separated by spaces. If IFS is null, the parameters are joined without intervening separators.

:* (!)


Gostou do conteúdo?

Você também me encontra nessas redes!

Mastodon

@gutocarvalho@bolha.us

PixelFed

@gutocarvalho@bolha.photos

Lemmy

@gutocarvalho@bolha.forum

Matrix

@gutocarvalho@bolha.chat

WriteFreely

@gutocarvalho@bolha.blog @notamental@bolha.blog @poesias@bolha.blog @contos@bolha.blog

Bookwyrm

@gutocarvalho@bolha.review

Peertube

@gutocarvalho@bolha.tube

Funkwhale

@gutocarvalho@bolha.studio

Friendica

@gutocarvalho@bolha.network

Quer saber mais sobre mim?

Visite meus sites!

Conhece o Coletivo Bolha?

Então vem conhecer o bolha.io!

Nós temos muito mais para compartilhar contigo!

Conhece o HackSpace da Bolha?

Vem conhecer o espaço que usamos para estudar o fediverso!

Nosso site

WriteFreely

Quer apoiar nosso trabalho? Você pode!

Te vejo no mastodon da bolha.us!

[s]