Script file name in a Bash script

0 votes
Can I determine the name of the Bash script file inside the script itself? If so, How?
Jun 20, 2019 in Linux Administration by Upasana
• 8,620 points
525 views

1 answer to this question.

0 votes

$0 will give you the complete basename. So, maybe something like the following;

 echo "Your filename is $0"
answered Jun 20, 2019 by Shubham
• 13,490 points

Related Questions In Linux Administration

0 votes
1 answer

Input file name in the mapper in a Hadoop program

Try this inside your mapper : FileSplit fileSplit ...READ MORE

answered Jul 23, 2019 in Linux Administration by Shubham
• 13,490 points
2,795 views
0 votes
1 answer

How to find the first field from a file in Bash Shell?

Hi@akhtar, You can extract text from a file. ...READ MORE

answered Oct 20, 2020 in Linux Administration by MD
• 95,440 points
817 views
0 votes
1 answer

Is there a limit on the number of words in bash command 'for file in words'?

Anyway, you need to print everything except ...READ MORE

answered May 27, 2022 in Linux Administration by Korak
• 5,820 points
346 views
0 votes
1 answer

How do I check if a directory exists in a Bash shell script?

To check if a directory exists in ...READ MORE

answered Jun 7, 2022 in Linux Administration by Korak
• 5,820 points
1,429 views
0 votes
1 answer
0 votes
1 answer

Restart python script automatically even when it crashes in Linux

Maybe this would be more robust? 1) save ...READ MORE

answered Sep 11, 2018 in Python by Priyaj
• 58,090 points
2,756 views
0 votes
1 answer

Restart python script automatically even when it crashes in Linux

Maybe this would be more robust? 1) save ...READ MORE

answered Sep 21, 2018 in Python by Priyaj
• 58,090 points
3,671 views
0 votes
1 answer
0 votes
1 answer

Writing a heredoc to a file in a script

try to use tee: tee newfile <<EOF line 1 line 2 line ...READ MORE

answered May 20, 2019 in Linux Administration by Shubham
• 13,490 points
1,276 views
0 votes
1 answer

How to extract file base name without path and extension in bash?

You don't actually have to call the ...READ MORE

answered May 31, 2019 in Linux Administration by Shubham
• 13,490 points
5,448 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP