bash - Python -c switch -
i have
".".join(str(z) z in [int(x, 16) x in (re.sub(r'(.{2})(?!$)', r'\1.', "00112233")).split('.')]) 'xx.xx.xx.xx'
which works when try use via python -c switch fails ?
[root@monty ~]# python -c "import re ; ".".join(str(z) z in [int(x, 16) x in (re.sub(r'(.{2})(?!$)', r'\1.', "00112233")).split('.')])" python -c "import re ; ".".join(str(z) z in [int(x, 16) x in (re.sub(r'(.{2})(?"import re ; ".".join(str(z) z in [int(x, 16) x in (re.sub(r'(.{2})(?python)', r'\1.', "00112233")).split('.')])")', r'\1.', "00112233")).split('.')])" -bash: syntax error near unexpected token `str'
any ideas ?
looks quoting issue on command line.
try wrapping python string in single quotes instead, , not using single quotes inside it.
you can escape quotes collide shell's interpretation, using \"
.
$ python -c 'import re;print ".".join(str(z) z in [int(x, 16) x in (re.sub(r"(.{2})(?!$)", r"\1.", "00112233")).split(".")])' 0.17.34.51
note: not running python interpretor more need explicitly print results.
Comments
Post a Comment