Does file extension matter in UNIX?

Thread Tools Search this Thread
Operating Systems Solaris Does file extension matter in UNIX?
# 1  
Old 09-19-2011
Does file extension matter in UNIX?

Hi friends,
I was wondering if UNIX programs really care about file extensions like Microsoft Windows applications do. Because I think an extension doesn't really change the nature of a file, or does it? But when I try to compile the c source code file named "hello", gcc gives me error, saying that hello is not a known file type. Any comments!
# 2  
Old 09-19-2011
UNIX doesn't when it comes to executing files. It checks the first few bytes of a file to figure out what type it is.

The behavior of other things depends on the program in question. gcc does care. When compiling a .c, it knows it's a C file. .cpp, it knows it's a C++ file. .f, might be fortran. (gcc's not just C -- it's the GNU compiler collection.) And so forth.

Things like makefiles also depend on file extensions -- when something depends on file.o, it knows it needs to gcc -c file.c or file.cpp to get it without having to be told to use file.c explicitly, which is very convenient.

Last edited by Corona688; 09-19-2011 at 02:35 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Code that has to end no matter what

Since this is maxxing out my CPU, is there anything I can add that will make sure stress always ends? echo "CPU Stress Test" >> CPU_Stress_Test.txt echo "stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 1m" >> CPU_Stress_Test.txt echo >> CPU_Stress_Test.txt date +"%Y-%m-%d-%H-%M" >>... (9 Replies)
Discussion started by: drew77
9 Replies

2. UNIX for Beginners Questions & Answers

Zipping the files in UNIX having extension after

Hi Folks I have a logs file at directory cd /opt/app/logs named as coa.log.1 uoa.log.2 erete-rere.log.1 now my concern is that i am looking for unix command which will zip the files having extension log.1 or log.2 or having log. extension anything request you to... (4 Replies)
Discussion started by: neerasri
4 Replies

3. Shell Programming and Scripting

Rename specific file extension in directory with match to another file in bash

I have a specific set (all ending with .bam) of downloaded files in a directory /home/cmccabe/Desktop/NGS/API/2-15-2016. What I am trying to do is use a match to $2 in name to rename the downloaded files. To make things a more involved the date of the folder is unique and in the header of name... (1 Reply)
Discussion started by: cmccabe
1 Replies

4. UNIX for Dummies Questions & Answers

Display the .csv extension files based on .done extension fine

Hi All, I want to fetch the files based on .done file and display the .csv files and Wil take .csv files for processing. 1.I need to display the .done files from the directory. i need to search for the .Csv files based on .done file.then move .csv files for the one directory ... (2 Replies)
Discussion started by: girija.g6
2 Replies

5. UNIX for Dummies Questions & Answers

creating separate directories according to file extension and keeping file in different directory as

unix program to which a directory name will be passed as parameter. This directory will contain files with various extensions. This script will create directories with the names of the extention of the files and then put the files in the corresponding folder. All files which do not have any... (2 Replies)
Discussion started by: Deekay.p
2 Replies

6. Shell Programming and Scripting

Terminal to the front no matter what

Is there a way to bring the terminal script to the front? I am running this script through OMCEdit which is then running it through Terminal. I have some dialog boxes (using osascript) and the dialog boxes are not coming to the front...Terminal bounces and I have to click on Terminal to see the... (1 Reply)
Discussion started by: mainegate
1 Replies

7. Shell Programming and Scripting

How to delete matter in between two lines

help I am having text file like this... ------------------------END OF UPDATION ------------------ xxxxxxxxxxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyyyy yyyyyyyyyyyyyyyyyyyyy 1 row updated ------------------------END OF UPDATION ------------------ TTTTTTTTTTTTTTTT FFFFFFFFFFFFFFFFF ... (3 Replies)
Discussion started by: suryanarayana
3 Replies

8. Linux

Need help with this matter

I have a PC that was built in Europe pre-installed with Windows 2000. The HDD is 40GB, but, its split up as two 20GB (Taken up by Windows). I want to take over my Mandrake 9.1 CDs and install Linux on that machine. My question is, how would I proceed to install Linux this way??? Now, If... (1 Reply)
Discussion started by: wardialer
1 Replies
Login or Register to Ask a Question