9879ypxkj
9879ypxkj

Reputation: 447

What does "-c" mean in this linux shell command?

It's from a tutorial on the google cloud platform, they call python from the Linux Shell. I'm totally new to gcp and linux, please help me, where can I find some exhaustive documentation for python tools in Linux?

python -c 'import base64, sys, json; \
  img = base64.b64encode(open(sys.argv[1], "rb").read()); \
  print json.dumps({"key":"1", "image_bytes": {"b64": img}})' \
  flower1.jpg > request.json

Upvotes: 5

Views: 6436

Answers (3)

Ilyes KAANICH
Ilyes KAANICH

Reputation: 346

-c stand for cmd which allows you to pass your code as a string. This feature is available even outside of google-cloud-platform. you can check other available options using python -h

Upvotes: 3

Gustav Rasmussen
Gustav Rasmussen

Reputation: 3971

the -c flag means execute the following command as interpreted by this program.

Doc: https://askubuntu.com/questions/831847/what-is-the-sh-c-command

Upvotes: 2

Pratik Joshi
Pratik Joshi

Reputation: 439

When called with -c command, it executes the Python statement(s) given as command. Here command may contain multiple statements separated by newlines. Leading whitespace is significant in Python statements!

Upvotes: 1

Related Questions