Thursday, 20 September 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...