Thursday, September 20, 2018

bash - Variable Parameters to bashrc alias

Say, I have a command in bashrc alias which might require variable arguments/parameters. I was able to write it using if else as follows



yd(){
if (( $# )) && (( $1 == 1 ));
then
youtube-dl -f 18 "$2" && aplay /usr/share/sounds/ubuntu/stereo/message.ogg && notify-send 'Youtube Download Completed !'
fi
if (( $# )) && (( $1 == 2 ));
then
youtube-dl -f "$2" "$3" && aplay /usr/share/sounds/ubuntu/stereo/message.ogg && notify-send 'Youtube Download Completed !'

fi
}


Where 1st parameter represents the number of parameters I need. I want to know if there is a way to send variable number of parameters to the alias

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...