You are not logged in.
Pages: 1
Dear all,
I am doing some scripting works in our [c]SliTaz 4[/c] platform.
Managing the results of some of our efforts, I wanted to use part of a bigger keyword as the name for a folder I need to create.
I know there is [c]expr substr n m[/c] as the shell way to make such partial use of keywords. However, your implementation of the bourne shell has no provision for [c]substr[/c]. Is there any way to overcome this lack of provision?
kind regards,
Antonio
Offline
Hi arodulfo,
I found BASH examples in the google:
BASH example 1:
[c]stringZ=abcABC123ABCabc
# 123456789......
# index starts from 1
echo $(expr substr $stringZ 1 2) # ab
echo $(expr substr $stringZ 4 3) # ABC[/c]
BASH example 2:
[c]stringZ=abcABC123ABCabc
# 0123456789.....
# index starts from 0
echo ${stringZ:0} # abcABC123ABCabc
echo ${stringZ:1} # bcABC123ABCabc
echo ${stringZ:7} # 23ABCabc
echo ${stringZ:7:3} # 23A
# return 3 symbols[/c]
SliTaz is small distro and not included BASH by default (but you can install it: [c]# tazpkg -gi bash[/c]), SliTaz use Busybox's ash (manpage ash). And better of all, second BASH example works on Ash!
Good luck in your scripting!
Offline
Actually expr is part of the coreutils and not the shell, so installing the coreutils-conditions package should solve this problem for you by providing the real expr rather than the busybox version.
Offline
@Aleksej, @Trixar_za:
Provided I can solve it with no additional installations, I would opt for Aleksej's hint.
I don't really want to get too far from initial SliTaz 4 config.
I'll try your hints and report my results back here ASAP.
Kind regards,
Antonio
Offline
@Aleksej: Brilliant! I never stop learning! It works as expected! Thank you so much. I needed just that!
Kind regards,
Antonio
Offline
Pages: 1
[ Generated in 0.017 seconds, 7 queries executed - Memory usage: 1.54 MiB (Peak: 1.77 MiB) ]