Programming Tutorials

basename in Mac OS X

By: Strauss K in macos Tutorials on 2011-02-03  

basename is a command in Mac OS X and other Unix-based systems that is used to strip the directory path and return only the base filename. It takes a file path as an argument and returns the base filename.

The syntax for basename is:

basename path [suffix]

where path is the file path and suffix is an optional argument that specifies a suffix to remove from the filename.

For example, if the file path is /usr/local/bin/script.sh, running the command basename /usr/local/bin/script.sh will return script.sh. If a suffix is specified, such as basename /usr/local/bin/script.sh .sh, the command will return script.

basename is often used in shell scripts to manipulate file names and paths.






Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in macos )

Latest Articles (in macos)