Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for line in intersect:
- cmd=""" grep "CHECKOUT_REVISION" |cut -d'"' -f2"""%fst_directory
- cmd_test=os.system(cmd)
- this is a test
- another line
- CHECKOUT_REVISION this must be stored
- some other things
- CHECKOUT_REVISION another line to store
- #!/usr/bin/env python
- # path to the file to read from
- my_file = "/home/eday/test.txt"
- # what to look in each line
- look_for = "CHECKOUT_REVISION"
- # variable to store lines containing CHECKOUT_REVISION
- temp = []
- with open(my_file, "r") as file_to_read:
- for line in file_to_read:
- if look_for in line:
- temp.append(line)
- # print the contents of temp variable
- print (temp)
- $ ['CHECKOUT_REVISION this must be stored', 'CHECKOUT_REVISION another line to store']
- result = []
- for line in open('filename'):
- if 'CHECKOUT_REVISION' in line:
- result.append(line.split(''"'')[1])
- some lines
- CHECKOUT_REVISION="revision one"
- some other lines
- CHECKOUT_REVISION="revision two"
- other lines
- revision one
- revision two
- #!/usr/bin/env python
- import sys
- pattern = sys.argv[1]
- fileName = sys.argv[2]
- # variable to store lines containing CHECKOUT_REVISION
- count=0
- temp = []
- with open(fileName, "r") as file_to_read:
- for line in file_to_read:
- if pattern in line:
- #IN case you want to have number of hits
- count=count+1
- temp.append(line)
- # print the contents of temp variable
- for i in range(count):
- print (temp[i].rstrip())
- python "pattern" thisScript.py
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement