iiitl / bash-practice-repo-24

0 stars 35 forks source link

#75 Added script to count lines in remote repository #115

Closed Priyanshu-2005 closed 5 months ago

Priyanshu-2005 commented 5 months ago

Fixes #75 Added script that count lines in remote repository

OUTPUT Command Used bash gitlines <repo_url> image

Command Used bash gitlines image

EXPLANATION OF CODE if [ "$#" -eq 0 ]; then Checks if no argument is passed then asks user to enter the repository name as argument

repo_url=$1 Stores the URL passed into the a variable named repo_url

temporary_directory=$(mktemp -d) Creates a temporary directory and stores it in the variable named temporary_directory

git clone "$repo_url" "$temporary_directory" Clones the given repository into the local system inside the temporary directory we created

cd "$temporary_directory" || exit Changes the present working directory into temporary directory

cloc $temporary_directory This command allows user to count no. of lines in the directory and displays them into the terminal according to the programming language

rm -rf "$temporary_directory" Removes the directory to prevent the storage from getting full. rm -rf is used to forcefully remove the files and folders.

ecxtacy commented 5 months ago

Perfect ! Nice work @Priyanshu-2005.