Arrays in shell scripting | indexed array vs associative arrays | ${Arr[@]} vs ${Arr[*]} in arrays

Поділитися
Вставка
  • Опубліковано 25 лис 2024

КОМЕНТАРІ • 26

  • @ishapandey40
    @ishapandey40 Рік тому +2

    i was hella confused for array indexing nd associative arrays but now all of my doubts are cleared thankyou sirr🙏

  • @kychemclass5850
    @kychemclass5850 Рік тому +1

    Tq for sharing this knowledge. Great Job!

  • @karthiselvam5968
    @karthiselvam5968 3 роки тому +5

    Omg!!! Best teacher you are....
    No one explains scripting this much clear...Great work...👏👏👏
    Please continue to post linux and scripting related videos...

  • @priyanujbora9089
    @priyanujbora9089 Рік тому +1

    Amazing playlist.

  • @lucky1984goel
    @lucky1984goel 2 роки тому +1

    Nice explanation 👍

  • @phucn5589
    @phucn5589 3 роки тому +1

    Teaching through showing differences. Plz Keep up great work!

  • @PedagogyV
    @PedagogyV  3 роки тому +6

    In case @ and * is still not cleared...here's another simple way to understand
    declare -a ARR=( "user1" "user2" "this is good" )
    for i in ${ARR[@]} # user1 user2 this is good [will loop five times]
    for i in ${ARR[*]} # user1 user2 this is good [will loop five times]
    above , no difference when used without quotes
    for i in "${ARR[@]}" # "user1" "user2" "this is good" [will loop three times]
    for i in "${ARR[*]}" # " user1 user2 this is good" [will loop one time]
    difference only exists , when quotes are used with them

  • @undefined6341
    @undefined6341 2 роки тому +1

    Great video! I hope your channel will get noticed. I don't even know if this channel is still going. But good stuff anyway!

  • @faniiii
    @faniiii 3 роки тому +1

    🔥🔥

  • @subee128
    @subee128 9 місяців тому

    Thank you 🙏🏻

  • @amintacce819
    @amintacce819 3 роки тому +1

    Thank you

  • @AbhishekSharma-uy1zv
    @AbhishekSharma-uy1zv 2 роки тому +2

    Hello Bro , forat of all nice video
    but i have a question if you can answer ,
    If java if we want to check the map contains a specific key of not we can use the contains method
    But in shell script how we can find that association array contains some specific key which we are providing or not

    • @PedagogyV
      @PedagogyV  2 роки тому +1

      For associative arrays in shell script , you can use ${!arr[@]} to print the keys of array. Later , you use the output of this command to check if your required key is in it or not.
      I had created some videos on array operations , you can check them out too to have better understabding.
      Thanks

    • @AbhishekSharma-uy1zv
      @AbhishekSharma-uy1zv 2 роки тому +2

      @@PedagogyV thanks bro this works for me

    • @AbhishekSharma-uy1zv
      @AbhishekSharma-uy1zv 2 роки тому +1

      @@PedagogyV but i have another doubt also , I want to read all the files and folder of current directory and also the files which are contained inside the folder of that directory , e.g I have a folder A which contains folder B and file Abc.txt and also folder B contains b.txt files and i want a program in shell script which read all the file names and folder name . I am finding some programs which can only read the folder B and abc.txt files when i am giving the path of folder A
      But i want also the files which are contained inside B Folder also. Can you suggest me how can i do that

    • @PedagogyV
      @PedagogyV  2 роки тому +1

      @@AbhishekSharma-uy1zv use ls -R to recusive print files.
      If you want to list out only .txt files as extension then better to use find command as find startdir -name "*txt".

    • @AbhishekSharma-uy1zv
      @AbhishekSharma-uy1zv 2 роки тому

      @@PedagogyV hello bro i am getting confusion in that , i want a shell script program which can read all the files and folder name recursively , i am doing reading of file name and folder name by for loop . Can you suggest me a beter way or provide me a link

  • @sreekrishnakittu61
    @sreekrishnakittu61 2 роки тому +1

    Hi bro , Can we pass values dynamically into array in shell scripting.?? Is that possible..??

    • @PedagogyV
      @PedagogyV  2 роки тому

      you can use this :
      stackoverflow.com/questions/38061047/filling-a-dynamic-array-with-user-input-in-shell-scripting
      ofcourse , you can also get input and then assign the value to array elements

  • @jayeshmahajan5775
    @jayeshmahajan5775 Рік тому +1

    how to delete or remove array elements