Path: utzoo!utgpu!water!watmath!clyde!att!mtunx!rutgers!cmcl2!brl-adm!umd5!cvl!mimsy!oddjob!kaon!nucsrl!squires From: squires@eecs.nwu.edu (Matthew Squires) Newsgroups: comp.unix.questions Subject: basename(1) (Was Re:argv[0] in shellscript?) Message-ID: <3680037@eecs.nwu.edu> Date: 7 Jun 88 00:55:21 GMT Organization: Northwestern U, Evanston IL, USA Lines: 41 / eecs.nwu.edu:comp.unix.questions / davidsen@steinmetz.ge.com (William E. Davidsen Jr) / 1:15 pm Jun 6, 1988 / > In article <1813@stpstn.UUCP> aad@stpstn.UUCP (Anthony A. Datri) writes: > | > | I want to write a script that will have multiple links to it, and be > | able to tell what name it was invoked with. Ideas? > > How about $0? That's the name of the called program. Watch out if you > have a full pathname (ie. $0 = foo/something). ... Then perhaps you could use basename(1)... BASENAME(1) UNIX Programmer's Manual BASENAME(1) NAME basename - strip filename affixes SYNOPSIS basename string [ suffix ] DESCRIPTION Basename deletes any prefix ending in `/' and the suffix, if present in string, from string, and prints the result on the standard output. ... % basename "foo" foo % basename "foo/something" something % Process shell finished > bill davidsen (wedu@ge-crd.arpa) > {uunet | philabs | seismo}!steinmetz!crdos1!davidsen > "Stupidity, like virtue, is its own reward" -me Matthew C. Squires, local GNUisance squires@eecs.nwu.edu OR {ihnp4,oddjob,gargoyle,chinet}!nucsrl!squires