Results 1 to 5 of 5
Windows depend on the extension of the file to decide its type:
.doc > Doccument
.bat > Batch File
.zip > Compressed File ...etc
What does Linux depend on to ...
- 06-29-2007 #1Just Joined!
- Join Date
- Aug 2005
- Posts
- 54
File Type In Linux
Windows depend on the extension of the file to decide its type:
.doc > Doccument
.bat > Batch File
.zip > Compressed File ...etc
What does Linux depend on to decide the type of the file?
Another Related Question:
in Windows u could save a test file as *.bat and it will work as command prompt
what should I save the text file in Linux so it would work as Terminal Program directly??
- 06-29-2007 #2Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
Nothing so primitive for Linux

You can use filetype associations, but ultimately the filetype is determined by a 'magic number'. If you look at shell scripts they always start withThe #! is the file start and it indicates that the file is an executable script. It's the same for most dedicated filetypes. For example, take a jpeg and remove the .jpg extension - it will still be recognised that it is a jpeg because the start of the file already indicates that it is. It is the same for most files, the exception being when a file is just a generic text file; .html, .xml, .txt for example. In this case the file extension is helpful.Code:#!/bin/bash
- 06-29-2007 #3Just Joined!
- Join Date
- Aug 2005
- Posts
- 54
in Windows u could save a test file as *.bat and it will work as command prompt
what should I save the text file in Linux so it would work as Terminal Program directly??
- 06-29-2007 #4
Right. You can use the 'file' command to find out what type of file a file is.
As far as making executable scripts, this is done by setting the executable permission. I have a big explanation on UNIX permissions at:
http://www.linuxforums.org/forum/lin...y-group-2.html
(about halfway down the page)
This allows you to execute the script by giving its absolute path. For instance, if I have a script at /home/user/my_script, I need to type out that entire path. If you want to be able to run the script from anywhere, you need to add it to a location in your $PATH variable. Just run the command:
to see all the locations that you could put it.Code:echo $PATH
DISTRO=Arch
Registered Linux User #388732
- 06-29-2007 #5
Linux uses what is called 'magic' , it identifies the files with the first bytes found in the file. For example #! are two 'magic' characters that define an script.
You don't need to name a file in a particular manner to make it run as a script, you write the magic, next the interpreter, make it executable and it should just work.
More info 'man magic'
For example:
#!/usr/bin/perl
will tell the shell that your script needs to be interpreted by the 'perl' binary found on /usr/bin
EDIT: All you are quickPut your hand in an oven for a minute and it will be like an hour, sit beside a beautiful woman for an hour and it will be like a minute, that is relativity. --Albert Einstein
Linux User #425940
Don't PM me with questions, instead post in the forums


Reply With Quote