Sunday, June 1, 2014

Fourth Week

Taking "diffs" for 2 files in linux:
               diff <path for file1><space><path for file 2>

Sourcing .sql files from a location to our db :
               1) scp <filename> user@hostip:<path to save this file in our machine>
               2) go to the file saved directory
               3) run mysql from that directory as : mysql -u root -p<password> and press enter
               4)select the database wher to source the files > use database; so now you moved into the database and then type "source <filename.sql>"

python
Reading file using python script
path = raw_input("Enter path to log file \n")
log = open(path)


In case of getting user input of a timestamp
yyyy,mm,dd,hh,mm = raw_input("Enter Start_Time in format(yyyy,mm,dd,hh,mm)").split(',')

use regular expression to get contents from a file
import re
re.search('^5', line)  ## this will get lines start with 5

python operations with "list"

eg : a=[66,333,333,1,1234] # a list of int
       print a.count(333) #result 2
       a.append(333)       #add element '333' to end of list
       a.reverse()             #reverse elements
       a.sort()                   #will give a sorted array of ascended values

python - defining a function and call function

eg: #print numbers in range which divisible by 2 and 3
#lets define a function def(fx)

def f(x): return x%2!=0 and x%3!=0
res=filter(f, range(0,1000))
print res

 
      

No comments:

Post a Comment