I have created a file called "testfile" and made it executable using chmod +x testfile
.
In order to execute the file "testfile" i need to run the command ./testfile
.
I need to know is there any way i could run the program without using ./
and execute the file using testfile
command?
Shown below is a simple code inside the file "testfile"
echo Todays date is :
date
$? is the exit status of the most recently-executed command; by convention, 0 means success and anything else indicates failure. That line is testing whether the grep command succeeded. The grep manpage states: The exit status is 0 if selected lines are found, and 1 if not found.
You can execute it without ./ by using:
sh testfile
Or
sh /path/to/file/testfile
Edit
If you want to execute the program directly with a command, what you can do is to define an alias:
alias execute_testfile="sh /path/to/file/testfile"
And then, you will execute the program whenever you write
execute_testfile
or whatever name you define.
To make this alias persistent, do include the alias ...
line in your ~/.profile or ~/.bash_profile files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With