Create Your Own Bash Script

No Comments
Bash scripting is one of the easiest types of scripting to learn. It run under Linux and its very usefull. Bash is the language that you will learn to love as much of everyday Ubuntu life is done/can be done using terminal. You can make your own custom bash script through both GUI (Graphical User Interface) and CLI (Command Line Interface), but I prefer using CLI than GUI because using CLI you can changing file permissions of a folder and all its sub folders is more easily.

To make your own custom bash script, define where you wanna put the custom bash script directory (I use /home/user/bash_custom).
Then run terminal by type ctrl + T and type, 
sudo nano /etc/profile
Add path of the custom bash script at the end of line, in order to execute the script from everywhere at the console,
export PATH=${PATH}:/home/user/bash_custom
Reload your system PATH in /etc/profile by type in terminal,
. /etc/profile
Create .sh file in bash_custom directory,
nano /home/user/bash_custom/youdl.sh
This script used to download youtube video with custom parameter and now integrate with axel downloader, of course I will share the script to you (make sure that you have youtube-dl installed before), copy and paste the following code to .sh file that have been created,

#!/bin/sh
CONNECTIONS=4 # Specify how many connections axel should use
# Get URL and Title of video using youtube-dl
url=`youtube-dl --get-url --max-quality avi  $1`
echo "Got URL"
title=`youtube-dl --get-title $1`
echo "Got Title :"$title
# Download using axel
axel --alternate --num-connections=$CONNECTIONS --output="$title.mp4" "$url"
Save it by type ctrl + O then type ctrl + X to exit.
Once finished, you can type in terminal
youdl.sh youtube_link_video title
Replace youtube_link_video with youtube video you want to download, and replace title with your custom title.

That's how this custom bash script work, just create other custom bash script, and do above steps.
Next PostNewer Post Previous PostOlder Post Home

0 comments

Post a Comment