Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (9.5k points)

I want to write a script to run .jar files as daemons. I used ‘vi’ to create a file but I don’t know how to define the file specifically to be a .sh file. For example, let’s say the file is ‘foo’ or ‘foo.txt. I want to convert it to ‘foo.sh’. 

Can anyone tell me how to create a .sh extension file in Linux?

1 Answer

0 votes
by (19.7k points)

Below is the code template: 

#!/bin/bash

# content of your script

This is called a shebang line which tells the OS what program it should execute. Here, it’s bash. 

Code to make the file executable:

chmod 755 foo.sh

Code to execute the script : 

./foo.sh

Interested in Linux? Check out this Linux Certification by Intellipaat.

Related questions

0 votes
1 answer
asked Nov 20, 2020 in Linux by blackindya (18.4k points)
0 votes
1 answer
0 votes
0 answers
asked Jun 24, 2021 in Linux by akhil.singh0123123 (320 points)
0 votes
1 answer
asked Dec 12, 2020 in Linux by blackindya (18.4k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...