Expand Tilde to Home Directory When Reading User Input in Bash

Опубликовано: 30 Сентябрь 2024
на канале: Nick Janetakis
301
30

For example "~" will turn into "${HOME}" to let a user set a custom path in a script.

Hit the subscribe button to receive more videos like this!

REFERENCE LINKS
---------------------------------------------------
► https://nickjanetakis.com/blog/expand...

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

► https://nickjanetakis.com/courses/

THE TOOLS I USE / GEAR
---------------------------------------------------
► https://nickjanetakis.com/blog/the-to...

FOLLOW ME ELSEWHERE
---------------------------------------------------
► Twitter:   / nickjanetakis  
► GitHub: https://github.com/nickjj

TIMESTAMPS
---------------------------------------------------
0:00 -- Intro
0:34 -- Running the script to see how it works
1:22 -- Only replacing the tilde if it's the first character
2:08 -- Replacing all instances of the tilde with the home directory
3:12 -- It's up to you on which one to pick