awk commands within python script

前端 未结 2 1359
闹比i
闹比i 2021-01-02 11:21

I need to write a python script where I need to call a few awk commands inside of it.

#!/usr/bin/python
import os, sys
input_dir = \'/home/abc/data\'

os.ch         


        
2条回答
  •  清歌不尽
    2021-01-02 12:14

    You have both types of quotes in that string, so use triple quotes around the 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'
    

提交回复
热议问题