Convert to string

Hello there!
I’m using :os.cmd() to run some shell command, and after I ran it I got a output string wrapped into single brackets, something like this '"string"', elixir tell me that it has a list type, how I can convert it to simple string?

List.to_string will give you "\"string\"" back.

Why don’t you use System.cmd? It will return stdout as a string and the exit code in a tuple as far as I remember and can also return a stream of lines.

As I’m on a mobile it’s troublesome to look the details up and post a link to the docs. I try to remember to do so once I’m back at a computer (not before next week probably).

2 Likes