Home > Software design >  Is there a way to make your own custom terminal command via .sh and .py?
Is there a way to make your own custom terminal command via .sh and .py?

Time:03-20

So you know how all coding languages usually have a terminal command to run it, like this:

python3 main.py

And then it runs whatever is in 'main.py'? I'm trying to make something similar to that, except it's for txt files, so when you run:

CUSTOM greeting.txt

It will tell Python to read everything in greeting.txt, so if 'Hello' is in greeting.txt, and you run CUSTOM greeting.txt, it will print out 'Hello' in terminal. Any help is appreciated!

CodePudding user response:

In your example case, alias CUSTOM=cat in your shell to have cat do the heavy lifting, but in general, yeah, just like Python or any other program can read command line arguments, so could your hypothetical interpreter.

If you were to implement your language in Python, I'd tell you to look at sys.argv...

  • Related