I know this is a silly question, but since I am trying so hard to learn linux by myself, I need some help from you fellows.
I found this task on the internet and I am trying to solve it but I don't understand exactly how can I use makefiles in linux and how can I create them.
Let's suppose my print working directory is /home/george/Documents
I want to create a makefile which does the following:
- Displays a message as follows "hello work, today is Sun". Sun comes from Sunday. So I must use
date
command in this make file to display just first three letters. compress
/etc/hosts
in/tmp
usinggzip
(probably here should be something likegzip -c SOURCE DESTINATION # ??
Cheers
to answer your question I cant give you a one line / paragraph answer because it deals with every thing.Read the first link it have everything you need with examples too.
Good tutorial that can explain everything about make
A Makefile is used as a "map" for C programs compilation. They work with the
make
utility, an describe how a program has to be compiled/linked in order to work correctly once turned into a executable file. For global UNIX/shell tasks, you're looking for shell scripts, not makefiles :)See http://en.wikipedia.org/wiki/Make_(software)#Makefiles for more information about makefiles, and http://en.wikipedia.org/wiki/Shell_script to discover shell scripts.
A basic shell script for what you're trying to do could be :
Store this in a file, and execute it using your shell prompt (
bash myscript.sh
,sh myscript.sh
, ...). You can also make the script executable using :And then execute it with your default interpretor with :
Why not create a shell script, then create a symbolic link that points to the shell script you created? Place the symbolic link in a directory that's in the PATH, so that you can 'run' the symbolic link no matter the directory in which you are located.