So far I managed to create a variable which stores the string and replaced blank with _
and :
with @
title=$(youtube-dl --get-title https://www.youtube.com/watch?v=8b1JEDvenQU)
echo "${title}"
echo "${title}" | sed 's/ /_/g;s/:/@/g'
XGBoost Part 2: Classification
XGBoost_Part_2@_Classification
I want to assign
mod_title -> ${title}" | sed 's/ /_/g;s/:/@/g'
and use this variable to use inside a function but I am not able to assign and print it.
This is what I have tried:
title=$(youtube-dl --get-title https://www.youtube.com/watch?v=8b1JEDvenQU)
mod_title = "${title}" | sed 's/ /_/g;s/:/@/g'
echo "${mod_title}"
error:
b.sh: line 2: mod_title: command not found
I am new to bash scripting. So no idea how to do it.
tr
for single character transliteration.sed
is needlessly heavy for this. Or, just use${variable//pattern/text}
twice. – Kusalananda Dec 06 '20 at 18:31