Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
can some body tell me what is the command to know the extension of the file?
for eg:
if i have a file called lol.txt , will it be command to know this file is a .txt file?
I am missing something here.....Can you not just do a listing (ls) and look at the file names?
Please give more information about what you are trying to do.
linux doesn't really use file extensions like windows does.. It's more of a place holder. the file lol and lol.txt are essentially the same file and linux doesn't really know the difference. You can do a vi on them both and get the same results. It just makes things easier for people coming over from windows to see a file with a .txt to know that is a text file.. OR if you are transferring data from a linux PC to a windows PC and you want to be able to read that file in notepad you'll need the .txt extension so you can open it automatically by clicking on it rather than, right click, open with, notepad.
maybe i'm over thinking what you are asking.. If you just want to see that lol.txt has a txt extension you just do
ls
or
ls -l
In the Unix world, it treats all files as either ASCII or Binary, it's really either or if given in a nutshell. I won't go into devices or the such but yeah, extensions are really just to let you know what type of file it is.
I am missing something here.....Can you not just do a listing (ls) and look at the file names?
Please give more information about what you are trying to do.
I back up pixellany 'ls' shows all files by their name. If their name is lol.txt or lol.txt.txt.txt or lol-txt-txt it does not matter its just the file name. The txt in the name just helps us know its an ASCII instead of a binary file.
Quote:
Originally Posted by trickykid
In the Unix world, it treats all files as either ASCII or Binary, it's really either or if given in a nutshell. I won't go into devices or the such but yeah, extensions are really just to let you know what type of file it is.
I never thought about that but your right. Humm learn something everyday. ;-)
it looked like he was asking how to verify the type of the file regardless of the extension..
His example even states he has a file called lol.txt and wanted to know how to verify it is indeed a text file
in which case the file command would be the proper one to use, as stated earlier.
it looked like he was asking how to verify the type of the file regardless of the extension..
His example even states he has a file called lol.txt and wanted to know how to verify it is indeed a text file
in which case the file command would be the proper one to use, as stated earlier.
Actually he's explicitly asking how to verify that a .txt file
is a .txt file (not "a file containing text"), and asks in the
title to know the extension type, which brings us back to
visual examination and ls ;}
The command stat will also do. Along with ls like mentioned. I think it's good though that myself and other members explained how files are treated in *nix, just an added detail to benefit the OP.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.