Value In Brief – by Abanoub Hanna
All You Need To Know Explained In Brief

How to Create Bash Function ?

Bash CLI Linux Mac OS X

First step: create a file to add all your bash functions in it.

2nd step: add your bash function/s like this.

echo -n "Enter source mp4 file : "
read sourceFile

echo -n "Enter destination mp3 file : "
read destFile

avconv -i $sourceFile -vn -acodec libmp3lame -ac 2 -ab 160k -ar 48000 $destFile

I created a bash function to convert mp4 video file to mp3 audio file from command line.

3rd step: source the Bash file


Finally, you can call the function from the command line (terminal) and use it like this.

$ convertMP4toMP3
Enter source mp4 file : video.mp4
Enter destination mp3 file : audio.mp3
« Ubuntu boots to black screen after trying to... Convert Mp4 to Mp3 in Linux Terminal »