Master Ian (whom I would link to, if his blog were not continually DOWN), showed me a very simple yet useful command:
1 | basename |
.
You give it the path to a file, it gives you the filename and extension. If you also give it the extension, it just gives you the filename. Thus:
sam@ZenSam:~$ basename unique-ip-list.csvunique-ip-list.csvsam@ZenSam:~$ basename unique-ip-list.csv .csvunique-ip-list
This could be quite useful in shell scripting, to grab a list of desired for various purposes. One implementation I thought of right off: If you wanted to throw an error message for the usage of a command in a script, instead of having it display “See /usr/bin/zip for details” or something similar, you could run it through basename, and get a better looking name.
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.








