I am using Ubuntu 12.04 LTS and I am stuck at creating a simple .bin file which can print a message "hi" or anything else. My objective is to create a binary file.I have searched but didn't found anything helpful to me. So may I know how can I create a .bin file.
12 Answers
Extensions are irrelevant, you can name a file dead.letter and it can still print "hi".
The following terminal commands will create a file named hello.bin, make it executable and print "hello" when executed:
cat > hello.bin <<EOF #!/bin/sh echo Hello World EOF chmod +x hello.bin Executing ./hello.bin gives:
Hello World This is a shell script, interpreted by the /bin/sh program (which is actually the /bin/dash program on Ubuntu).
The following writes source code to hello.c, the following command creates a binary program from this code:
cat > hello.c <<EOF #include <stdio.h> int main(void) { puts("Hello World"); return 0; } EOF gcc hello.c -o hello.bin Executing ./hello.bin gives you Hello World too.
I am new to ubuntu community but had this as a bookmark on my browser. You can see if this helps.
2