report which line of script we are at



This may have been discussed here but I'm not thinking of a good
string to find it with,

I wondered if a shell script can be made to report which line a
function that gets called is on.

I'm thinking of something like the perl code below that does that.
I use it to help debug scripts and in this case showing where in the
script this usage() function was invoked.

if(! $somevalue){
usage();
print "USAGE tripped at Line: <". __LINE__.">\n";
exit;
}

` __LINE__ ' carries the line number as value

Is there a handy way to do that in a shell script?
.



Relevant Pages

  • Re: Fetch the newest file containing the string fgractg*.log in the filename and contains the string
    ... On 2005-10-12, kartik wrote: ... > I am trying to develop a shell script that checks whether the newest ... > file modified today that contains the string 'fgractg*.log' in the ... mind. ...
    (comp.unix.shell)
  • Re: bash: how to echo to the prompt without executing
    ... On 2006-12-27, Berk Birand wrote: ... I then found out about this newsgroup, and figured I could try it ... some string to the bash prompt without actually executing it. ... from within a shell script or function, or even in C or Perl. ...
    (comp.unix.shell)
  • need help with simple script
    ... I need a little help with a simple shell script. ... list the files in the current directory that start with the letters qrt. ... Then I need to cat those files and grep for the string "not disinfected". ... that are created in a quarantine directory by an anti-virus product. ...
    (comp.unix.shell)
  • bash: how to echo to the prompt without executing
    ... I then found out about this newsgroup, and figured I could try it ... some string to the bash prompt without actually executing it. ... Once s/he is done, pressing ... from within a shell script or function, or even in C or Perl. ...
    (comp.unix.shell)
  • formatting a string
    ... I am writing a shell script that will change some file names ... around but am having trouble formatting a string. ...
    (RedHat)