Home Why isn't echo "$0" printing the script name in bash?
Reply: 0

Why isn't echo "$0" printing the script name in bash?

user722
1#
user722 Published in July 20, 2018, 2:26 pm

This question already has an answer here:

  • Reliable way for a bash script to get the full path to itself? [duplicate] 23 answers

In school I learned that "$0" would be the name of the script in bash, but when I try to print it, it actually prints -bash instead of the scriptname.

#!/bin/bash
echo "$0"

Output: -bash

Is there something I missed, or is there another command to get the name of the script?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.408594 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO