what's find the extention of a file in linux?
hi,
Is there a program in linux that will give me the extention of a file? Thanks in advance. |
try "file thisfile.ext"
replace thisfile.ext with your file it should tell you alot about the file |
ah, great.!
Thanks |
What do you mean by "give me the extension of a file"
Do you want a command to separate the extension from a filename? Actually file extensions are a just a convenience in linux. |
I mean what command will separate the extension from a filename?. I know file gives me tons of information about the file. But is there a program that will just give me the extention?
|
I guess the point is - extensions don't mean anything in linux, exept to the user maybe... Document files, OOo and such, still use the concept, but mainly for the users benifit...
|
window managers depend heavily on extensions for file association purposes. Some are smart enough to figure out the file type by the contents, but that is not a reliable method, as with Windows, there is no resource fork (as you have on a Mac), file extension association is possibly the best way for the environment to decide which program should open it.
|
try this:
Code:
for i in $(ls); do echo -n "$i: "; echo $i | sed 's/^.*\.\([^.]*\)$/\1/'; done For each of those it echos what it is working with and then uses 'sed' to rip off everything after the last '.' and shows that too. HTH |
For icon use, maybe, tho konqeror still knows a OOo file without the extension, etc, tho it may give a generic OOo rather than calc icon... Image files etc still preview and so forth. I don't see the extension as much of an issue IME...
|
Quote:
It's fantastic that konqueror remembers which app created which document, but it's hardly an ideal setup. --Kim |
You are probably right. It's not something I worry over and the apps tend to place extensions accordingly... So for data files the extensions are useful, but not necessary with execuatables...
Actually I'm not sure what KDE does, as you can copy and duplicate given files, trasfer across machines, etc, and KDE still seems to have some idea of what they are, tho not always perfectly. Some sort of file preview, I'd say. |
you could type :
Code:
file FILENAME | awk '{ print $2 }' |
Code:
$ sed 's/.*\.//' <<<"toHTML.php" |
Quote:
|
Thanks for restating what I already said. However the system isn't perfect - sometimes it cannot figure out the type based on the contents, but can based on the extensions.
Some environments are smart enough to figure it out based on the contents but not all, and of course it will vary depending on which versions of various libraries are installed. Thanks for trying to play semantics though. |
All times are GMT -5. The time now is 12:42 PM. |