Even if you're treating a variable as an array, you can still get the number of characters in the variable by typing _echo "${__#string__[0]}"_ which will display the exact number of characters in your string, as opposed to the shell returning a "1" as normal. This channel is awesome, with lessons that are easy to follow; sub-freakin-scribed.
I watched some videos of you from 2013 (uploaded 2 years ago), and have to tell, that your teaching skills improved a lot, your videos are more enjoyable and faster. Thank you very much for uploading new lessons!
thank you sir for guiding us you are the mentor for not only me but for all those who can't afford the better education by paying the money thank you this means a lot to me sirg
Small note on numbers, indexes and ordinals (1st, 2nd, 3rd ...). Given the array `pets=(cat, kea, crocodile)`. The first index of the Array is 0. The Element at index 1 is "kea". It's the 2nd element of the array, but its index is 1. However it is the 2nd Index. The first index is zero. There is no such thing as an zeroth element. The 2nd element is at the second index, but the name of the index is 1. Which doesn't make it the first index. It's the index one.
Or you can better put it in this way- index number means the distance of all subsequent elements in a list(or array) from the first element. Here, "cat" is your first element in list, so the distance of "cat" from "cat" is 0 (same element) and kea is 1 slot away from cat so it has index 1. Similarly, crocodile has index 2 and so on...
I'm trying to take input value from User and then try to pass the value so that it can automatically print the value in the array : #! /bin/bash
os=('kali','windows','ubuntu') echo -e "Enter the array pos" read arr echo "${os[$arr]}" Enter the array pos : 1 the value i get is blank...... how do I parse this value so that the array value can be returned ?
8 months later but maybe it will still be useful to you or someone else: #! /bin/bash os=( windows ubuntu kali ) #spaces between elements not comma read -p "enter the item position: " arr echo "${os[$arr]}"
@@shrikantsawant196 No sure what you want to do. In the example above with the os array you can just add another line to your script, echo $arr > my_new_file, or if you want to write something like argument number 2 is ubuntu, you can write echo "$arr is ${os[$arr]}" > my_new_file
Even if you're treating a variable as an array, you can still get the number of characters in the variable by typing
_echo "${__#string__[0]}"_
which will display the exact number of characters in your string, as opposed to the shell returning a "1" as normal.
This channel is awesome, with lessons that are easy to follow; sub-freakin-scribed.
I spent all days searching for a good tutorial and finally I find this....... Thxxxxxxxxxx A MILLION 🌹
I watched some videos of you from 2013 (uploaded 2 years ago), and have to tell, that your teaching skills improved a lot, your videos are more enjoyable and faster. Thank you very much for uploading new lessons!
thank you sir for guiding us you are the mentor for not only me but for all those who can't afford the better education by paying the money thank you this means a lot to me sirg
i stared learning programing fom u i mean c languge im gonna watch this in the coming summer god bless u
Hi Sir,The way you are presenting is awesome.Its very easy to understand.Thanks much :)
Thanks for the video, had all the information I needed.
Small note on numbers, indexes and ordinals (1st, 2nd, 3rd ...).
Given the array `pets=(cat, kea, crocodile)`.
The first index of the Array is 0. The Element at index 1 is "kea". It's the 2nd element of the array, but its index is 1. However it is the 2nd Index. The first index is zero.
There is no such thing as an zeroth element. The 2nd element is at the second index, but the name of the index is 1. Which doesn't make it the first index. It's the index one.
Or you can better put it in this way- index number means the distance of all subsequent elements in a list(or array) from the first element. Here, "cat" is your first element in list, so the distance of "cat" from "cat" is 0 (same element) and kea is 1 slot away from cat so it has index 1. Similarly, crocodile has index 2 and so on...
Very good tutorial
What is the maximum number of subscripts bash allows in Array? And how to increase that limit?
Good one for beginners
How to take array input from user of a specific array size????
how can i get manual page abouth these array variable features. man array does not returning manual page.
Great. 👏👍🏻
Very clear 👌 👏
can we put any number as array element?
how to print the index of any array value from the given array...
Good 👍👍🙂☺️
Pls use white theme background
Nice🔥
I'm trying to take input value from User and then try to pass the value so that it can automatically print the value in the array :
#! /bin/bash
os=('kali','windows','ubuntu')
echo -e "Enter the array pos"
read arr
echo "${os[$arr]}"
Enter the array pos : 1
the value i get is blank......
how do I parse this value so that the array value can be returned ?
8 months later but maybe it will still be useful to you or someone else:
#! /bin/bash
os=( windows ubuntu kali ) #spaces between elements not comma
read -p "enter the item position: " arr
echo "${os[$arr]}"
@@valentin-catalin1859 Thank you! yes, you're correct. I figured it out later.
@@valentin-catalin1859 how can i redirect read output to a file?
@@shrikantsawant196 No sure what you want to do. In the example above with the os array you can just add another line to your script, echo $arr > my_new_file, or if you want to write something like argument number 2 is ubuntu, you can write echo "$arr is ${os[$arr]}" > my_new_file
Awesome
it works without single quotation in array
removing ubuntu with mac is blasphemy
Fail...
👌👌👌
blurring the video by showing code and ouput