Linux awk sed R script python script input variable, awkpython

Source: Internet
Author: User

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.