awk commands within python script -


i need write python script need call few awk commands inside of it.

#!/usr/bin/python import os, sys input_dir = '/home/abc/data'  os.chdir(input_dir) #wd=os.getcwd() #print wd os.system ("tail -n+2 ./*/*.tsv|cat|awk 'begin{fs="\t"};{split($10,arr,"-")}{print arr[1]}'|sort|uniq -c") 

it gives error in line 8: syntaxerror: unexpected character after line continuation character

is there way can awk command work within python script? thanks

you have both types of quotes in string, use triple quotes around whole thing

>>> x = '''tail -n+2 ./*/*.tsv|cat|awk 'begin{fs="\t"};{split($10,arr,"-")}{print arr[1]}'|sort|uniq -c''' >>> x 'tail -n+2 ./*/*.tsv|cat|awk \'begin{fs="\t"};{split($10,arr,"-")}{print arr[1]}\'|sort|uniq -c' 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -