As recently blogged, here's the actual reverse process of stripping and removing non-directory suffix from a complete path filename. This blog entry is here to discuss and show on how to remove non-directory suffix of a path filename and retain only the directory name.
In short, stripping the non-directory suffix from /var/cache/named/etc/named.conf would only return the string value of /var/cache/named/etc/ .
Here's how to strip and remove the non-directory strings or suffix of a filename using the linux binary command dirname.
Man DirName
Dirname strips non-directory suffix from file name. If the specified input filename contains no /’s characters, dirname outputs ‘.’ (meaning the current directory) only. Dirname is part of coreutils linux package.
DirName Usage
Dirname Example 1:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# dirname test.txt
output:
.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dirname Example 2:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# dirname /var/backup/vertito/Favorites/Links/www.domain.conf.url
output:
/var/backup/vertito/Favorites/Links
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dirname Example 3:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# dirname /etc
output:
/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the pattern alright.
This dirname command can be handy on retrieving only the directory path of a complete filename with directory path strings. You can combine he command with other linux shell and command line commands to achieve your other desired output specially on string manipulation.
Enjoy!
Subscription
Categories
- HowTos (612)
- Linux Devices (40)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
▼
2007
(340)
-
▼
December
(38)
- Holiday Linux
- HowTo: Chikka messenger over GAIM Pidgin Messenger
- HowTo: Rename Multiple Files Without A Script
- HowTo: KDocker/AllTray - System Tray Docking
- HowTo: Thunderbird - News/Feed Reader
- HowTo: ThinFeeder - RSS/RDF/Atom Aggregator
- HowTo: Sage - Firefox Feed Reader Extension
- HowTo: Snownews - RSS/RDF Newsreader
- HowTo: Planet - RDF/RSS/Atom Feed Aggregator
- HowTo: Liferea - RSS/RDF Feed Reader
- HowTo: Blam - RSS/RDF Feed Reader
- Switching Hospital Systems to Linux
- HowTo: CSS Editor and Validator Install
- HowTo: Ebook Reader Install
- vertito's blogspot anniversary
- HowTo: Install 113 Amazing Fedora Games Part 8
- HowTo: Install 113 Amazing Fedora Games Part 7
- HowTo: Install 113 Amazing Fedora Games Part 6
- HowTo: Install 113 Amazing Fedora Games Part 3
- HowTo: Install 113 Amazing Fedora Games Part 2
- HowTo: Thunar File Manager
- HowTo: LeafPad Extremely Fast Text File Editor
- HowTo: View Bzipped file On-The-Fly
- HowTo: TuxPaint Drawing Program Installation
- HowTo: InkScape Drawing Program Installation
- HowTo: Adobe Flash Player on Fedora 8
- HowTo: Install Digital Comic Reader
- HowTo: Install 113 Amazing Fedora Games
- HowTo: Translate Find Statements to Perl Codes
- HowTo: Single Step VirtualBox Installation on Fedo...
- CLI Tip: Control Terminal Keystroke Combinations
- CLI Tip: Clearing Terminal Screen
- HowTo: Linux Aliasing Aliases
- HowTo: Move Multiple Files Recursively
- HowTo: Rename multiple files recursively
- HowTo: Strip Non-Directory Path Suffix from FileName
- HowTo: Generate Pronounceable Random Passwords
- HowTo: Determine RedHat and Fedora release version
-
▼
December
(38)
Saturday, December 1, 2007
HowTo: Strip Non-Directory Path Suffix from FileName
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy
0 comments:
Post a Comment