Simple "Variable" Bash File
The first argument to the script will be in $1
. You can use a bash string replacement to pull the extension; this removes everything from the last occurrence of .
forward, and stores the result in $filename
:
filename="${1%.*}"
Then you can use $filename
in your script wherever you want:
nasm -f elf "$filename.asm"
ld -s -o "$filename" "$filename".o io.o