Linux awk sed R script python script input variable, awkpython
Sed input variable:
1 chrI = "chr2"; sed-n "/$ chrI/p" clippointpos.csv # The variable is represented by $ var. Change the single quotes of sed into double quotes.
Awk input variables:
1 chrI = "chr2"; awk '/' "$ chrI" '/{print $0}' clippointpos.csv # The variable is represented by $ var, and '"is added to both sides of the variable '"
R script input variable:
1 arg <- commandArgs(T)2 filename=arg[1]3 outputfile=arg[2]
Input variable in python script:
1. OptionParser passing Parameters
1 from optparse import OptionParser 2 def main(): 3 usage = "usage: %prog [options] arg" 4 parser = OptionParser(usage) 5 parser.add_option("-f", "--file", dest="filename", 6 help="read data from FILENAME") 7 parser.add_option("-v", "--verbose", 8 action="store_true", dest="verbose") 9 parser.add_option("-q", "--quiet",10 action="store_false", dest="verbose")11 (options, args) = parser.parse_args()12 if options.verbose:13 print "reading %s..." % options.filename14 15 16 if __name__ == "__main__":17 main()
2. pass variables in the sys module
1 import sys2 print sys. argv [0] # python program name 3 print sys. argv [1] # The first input variable