I'm trying to find a way to properly get only the name of the directory that im in currently. If im in a directory called HW04, and pwd prints out home/zachary/HW04, how would i print out only HW04? Or is using pwd in order to get the name to much? any simpler methods?
Thanks in advance.
You could use
echo $(basename $(pwd))(or justbasename $(pwd)if you want to print it); see basename(1), pwd(1) (perhaps a shell builtin) and the command substitution section ofbashreference manual.You might find some bash prompt configuration to set your prompt to tell you such things.