Splitting Strings by a Delimiter with IFS or Bash's String Replace

preview_player
Показать описание
We'll handle splitting on 1 character and multiple characters.

REFERENCE LINKS
---------------------------------------------------

COURSES
---------------------------------------------------
Courses I've created that focus on web dev and deployment topics.

THE TOOLS I USE / GEAR
---------------------------------------------------

FOLLOW ME ELSEWHERE
---------------------------------------------------

TIMESTAMPS
---------------------------------------------------
0:00 -- Intro
0:55 -- The use case of splitting a string by 1 character
1:44 -- Using read and IFS to split a string into an array
2:51 -- If you don't define IFS it'll use white space characters by default
4:27 -- Can you name a fruit with 2 words?
4:47 -- Splitting on multiple characters with IFS could be unexpected
5:48 -- Using Bash's parameter expansion and replacing strings
7:14 -- This method works with 1 character too
8:00 -- We're still using IFS with the Bash string replace method
9:21 -- Both methods work well most of the time but have footguns
9:44 -- Splitting in Bash is hard
Рекомендации по теме
Комментарии
Автор

I completely agree, everybody should consider bash as a tool with limited area of using. There's a list of reasons not to use bash in advanced bash scripting guide. Unfortunately, I don't see obvious match with the subject of this video, but, in my opinion, this example could be in that list easily.

nnutipa
Автор

Asian pear🍐, mad cucumber🥒(it's not a fruit, but sounds and deploys its seeds in a funny way).
Thanks for the video. You promised, you made it. Good quality in our times.
As for likes: understood IFS, but left variant looks way better. Could do
fruits_array=(${fruits//, orange, / })
Nice!

samoylov