Basename
From DssWiki
basename is a common program found on Unix systems; typically it is the GNU Project's coreutils version, which is Free software. Given a pathname, it will return the name of the file that the pathname refers to. For example, basename /home/john/pictures/cat.jpg will return "cat.jpg". While this may seem trivial and useless to humans, basename is a useful tool in shell scripts.
A related command is dirname, which returns the directory name without the filename. For example, dirname /home/john/pictures/cat.jpg will return "/home/john/pictures"
[edit] See also
[edit] External links
man|cu|basename|SUS|return non-directory portion of a pathname
man|1|basename||strip directory and suffix from filenames
{{#if: |
Unix command line programs and builtins (more) | |||
| File and file system management: | cat | chattr | cd | chmod | chown | chgrp | cksum | cmp | cp | du | df | file | fsck | fuser | ln | ls | lsof | mkdir | mount | mv | pwd | rm | rmdir | split | touch | ||
| Process management: | at | chroot | crontab | exit | kill | killall | nice | pgrep | pidof | pkill | ps | sleep | time | top | wait | watch | ||
| User Management/Environment: | env | finger | id | mesg | passwd | su | sudo | uname | uptime | w | wall | who | whoami | write | ||
| Text processing: | awk | comm | cut | ed | ex | fmt | head | iconv | join | less | more | paste | pg | sed | sort | tac | tail | tr | uniq | wc | xargs | ||
| Shell programming: | basename | echo | expr | false | printf | test | true | unset | Printing: | lp |
| Communications: inetd | netstat | ping | rlogin | traceroute | Searching: find | grep | strings | Miscellaneous: banner | bc | cal | dd | man | size | yes | |
