Can somebody help me with a sript to print the parent directory and sub directory name for a given directory. It should not print the file names inside the directories. I want only the directories name.
New Kid on the blog and Linux too---need help
Collapse
X
-
I'm a bit suspicious of the phrase "given directory". How is it "given"? My guess (and this may be entirely wrong) is simply that it means you know the name of a specific directory, e.g. /var/log/mail and you want to parse that into its own name "mail" and its parent's path name "/var/log" Is that what this is about?Originally posted by Good galCan somebody help me with a sript to print the parent directory and sub directory name for a given directory. It should not print the file names inside the directories. I want only the directories name.
If so, then check the commands "basename" and "dirname" as in:
If this is not what you're trying to do, please clarify your question.Code:[prn@deimos ~]$ basename /var/log/mail mail [prn@deimos ~]$ dirname /var/log/mail /var/log
Best Regards,
PaulComment
Comment