Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

how to create a bash script

#!/bin/bash

echo "Hello, world!"
Comment

bash make script

use below script to easilly create scripts with different types that are automaticaly set to executable

#!/bin/bash

version="1.0"

function help-text (){
	echo "-v : Show version"
	echo "-t : Type of script you want to create (bash/python3/...) defaults to bash"
	echo "-h : Show help text"
	exit 0;
}

args=("$@") 
ELEMENTS=${#args[@]}

if [[ $1 = "-h" ]]; then
	help-tekst
fi

for (( i = 0; i < $ELEMENTS; i++ )); do
	case ${args[${i}]} in
		"-"* )
			argument=${args[${i}]}
			for (( j=1; j<${#argument}; j++ )); do
			  	case "${argument:$j:1}" in
			  		"v"  )
						echo "Version: $version"
						;;
					"t"  )
						fileType=${args[${i}+1]}
						i=$i+1
						;;
					"h"  )
						help-text;
						exit 0;
						;;
					*	 )
						echo "-${argument:$j:1}" "invalid command, use -h for more info"
						;;
				esac
			done
			;;
		*	 )
			fileName=${args[${i}]};
			;;
	esac
done

if [[ -z "$fileName" ]]; then
	echo "No fileName was provided"
else
	if [[ -z "$fileType" ]]; then
		printf "#!/bin/bash
" > $fileName;
		chmod +x $fileName;
	else
		printf "#!/bin/$fileType
" > $fileName;
		chmod +x $fileName;
	fi
fi
Comment

how to create a bash script

echo '#!bin/bash' > filename 
# works with and without extention, if you want extention do filename.sh
chmod +x filename
Comment

create a bash script

#!/bin/sh
python /path/to/trc-image-titler.py -o /path/to/output
Comment

PREVIOUS NEXT
Code Example
Shell :: spaceship theme zsh 
Shell :: sed repeat pattern 
Shell :: add package in pubspec.yaml using command prompt in flutter 
Shell :: git passphrase remember 
Shell :: linux os update 
Shell :: cs50 docs 
Shell :: application version on ubuntu 
Shell :: linux command find executable 
Shell :: grep exclude multi dirs 
Shell :: vim colorscheme 
Shell :: cli echo to file 
Shell :: add my current project to an already existing GitHub repository 
Shell :: interact with docker container shell 
Shell :: github as database 
Shell :: github howto contribute fork 2 commits behind 
Shell :: conda install version 
Shell :: install composer v2 ubuntu 
Shell :: delete a branch in git command 
Shell :: kali metapackages detail 
Shell :: insert bash command to docker-compose file 
Shell :: linux remove packages 
Shell :: jupyter command install 
Shell :: how to save changes made to models in django 
Shell :: pip install six 
Shell :: what is sudo in linux 
Shell :: install clang++ 
Shell :: how to copy a Directory and its content in ubuntu 
Shell :: debian list packages automatic install 
Shell :: apache airflow install 
Shell :: linux help 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =