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

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -