[PYTHON] A note for embedding the scripting language in a bash script

20161209

I made a note because I was able to divert my knowledge from perl.

Python uses 2 series as an example

As function

#!/bin/bash
function py () {
    python -- <<'EOF' - "$@"
import sys
print sys.argv[1]
EOF

}

function ru () {
    ruby -- <<'EOF' - "$@"
    puts ARGV[0]
EOF
}

py python
ru ruby

By the way, hand it over with a pipe

$ echo python | python -c '
import sys

for i in sys.stdin:
    print i,
'
$ echo python | python -c 'print raw_input()'

Recommended Posts

A note for embedding the scripting language in a bash script
Note 2 for embedding the scripting language in a bash script
Change the list in a for statement
Run the Python interpreter in a script
Let's run a Bash script in Java
A useful note when using Python for the first time in a while
Create an executable file in a scripting language
Register a task in cron for the first time
Check if it is Unix in the scripting language
Check if it is Unix in the scripting language
A note on the default behavior of collate_fn in PyTorch
How to temporarily implement a progress bar in a scripting language
Create a script for your Pepper skill in a spreadsheet and load SayText directly from the script
Process the files in the folder in order with a shell script
[Note] A shell script that checks the CPU usage of a specific process in a while loop.
[Note] Import of a file in the parent directory in Python
Use a scripting language for a comfortable C ++ life-OpenCV-Port Python to C ++-
I wrote a script that splits the image in two
Use a scripting language for a comfortable C ++ life 5 --Use the Spyder integrated environment to check numerical data-
Process the contents of the file in order with a shell script
Created gomi, a trash can tool for rm in Go language
Save the Pydrive authentication file in a different directory from the script
[Introduction to Python] How to use the in operator in a for statement?
Change the bash prompt to a simple color for easy viewing
Dockerfile with the necessary libraries for natural language processing in python
Read the config file in Go language! Introducing a simple sample
How to determine if a shell script was started in bash
A programming language that young people will need in the future
Run a multi-line script in a PDB
Get the script path in Python
A little script for malware self-defense
Switch the language displayed in Django 1.9
Start SQLite in a programming language
A note for writing Python-like code
A story about trying to improve the testing process of a system written in C language for 20 years
Add syntax highlighting for the Kv language to Spyder in the Python IDE
Let's use a scripting language for a comfortable C ++ life 2 Automatically generate C ++ source
Use a scripting language for a comfortable C ++ life 4-Use your own C ++ library from a scripting language-
Guidelines for reincarnating in the world of linux programming development (C / C ++ language)
AtCoder writer I wrote a script to aggregate the contests for each writer
Use a scripting language for a comfortable C ++ life 3-Leave graphing to matplotlib-
View the full path (absolute path) of a file in a directory in Linux Bash
What Java users thought of using the Go language for a day
In creating a model for discriminating tweet emotions with LSTM + Embedding, I reaffirmed the importance of preprocessing in NLP.
The most sought after programming language in 2020
Write the test in a python docstring
Find the dates for a jarring tournament
Documents on approaches for embedding in ARM
Cut out A4 print in the image
Looking back on 2016 in the Crystal language
MongoDB for the first time in Python
Get a token for conoha in python
Draw graphs in the programming language Julia
Use Python3's Subprocess.run () in a CGI script
A note about doing the Pyramid tutorial
Arrange the numbers in a spiral shape
Use something other than a <br> string for the <br> dict key in Python
I searched for the skills needed to become a web engineer in Python
Python script to get a list of input examples for the AtCoder contest
Turn multiple lists with a for statement at the same time in Python
Instructions for connecting Google Colab. To the local runtime in a Windows environment