firstname.lastname@example.orgSimple Shell Scripting for Scientists: Appendix3
Appendix: Unix commands (1)
return the filename from a filepath, removing the givenending (if specified)
basename ~/hello.sh .sh
from a file path
If you have a path to a file,
will give you just the directory, removingthe actual filename whilst
will give you the filename, removing thedirectory path.
can also remove the endings of filenames.If you need to do more advanced filename (or file) manipulation,then youshould look at the
commands, which are covered in the “UnixSystems: Further Commands” course, the notes for which are available here:http://www-uxsup.csx.cam.ac.uk/courses/Commands/The
command searches for files in a directory tree, and having found thespecified files, can run a command on each file.The
command builds a command line from a combination of valuesread from standard input and arguments specified on the command line, andthen executes that command line a certain number of times.