Skip to content
Advertisement

how to create a linux shell alias to give to g++ compiler the path of the file to compile?

What I want to do it’s to create an alias for the sentence below:

JavaScript

Because I have to compile single files frequently.

To do it, I’m trying creating a txt file with the output file name and the path of the file to compile. So I have a txt, called tocompile.txt, file that contains:

JavaScript

then, I assign to a var that I call tocompile the content of tocompile.txt:

JavaScript

This is working, because if i do echo $tocompile I’m getting: test /home/me/test.cpp

So, then, I’m trying to create the alias doing:

JavaScript

It doesn’t work, when I do:

JavaScript

I get:

JavaScript

What’s the right way to do that?

Advertisement

Answer

Does

JavaScript

work for you? At least in my bash version that works.

But as already mentioned in my comment, I would recommend a simple Makefile for this job. Create a file called Makefile with the contents

JavaScript

and run make. Check out a tutorial, e.g., this one.

Advertisement