Wednesday, December 29, 2021

Find and copy File recursively on MAC terminal

The following command find allt he files with *jpeg extension with in the current folder/children folders recursicely and copy all the files to the ~/mac-photos folder
$ find . -name "*.jpeg" -type f -exec cp {} ~/mac-photos \;

Read More...

Monday, November 8, 2021

Code to Split large file and keep the header row on each file

You can pass a single argument as the file name(Exclude the extension...) or you can modify the file to take extension as the arguments.
fileName=$1
splitFileNamePrefix="${fileName}_"
header=$(head -1 ${fileName}.dat)
split -l 40000 ${fileName}.dat splitFileNamePrefix
n=1
for f in splitFileNamePrefix*
do
    prefixSplitNo=0
    if [[ ${n} -gt 9 ]]; then
        prefixSplitNo=''
    fi
    outputFileName="${splitFileNamePrefix}${prefixSplitNo}${n}.dat"
    echo ${outputFileName}
    if [[ ${n} -ne 1 ]]; then
        echo ${header} > ${outputFileName}
    fi
    cat ${f} >> ${outputFileName}
    rm ${f}
    ((n++))
done

Read More...

Saturday, September 12, 2020

Running a command as a service in Window!


To create service:
 sc.exe create YOUR_SERVICE_NAME binpath= <PATH_TO_YOUREXECUTABLE>
 
Example:  sc.exe create dockerDService binPath= "C:\Program Files\Docker\Docker\resources\dockerd.exe" start= auto



To delete service:
  sc.exe delete SERVICE_NAME 
 Example : sc.exe delete dockerDService 

Note: Use PowerShell or the command Terminal with Administrator mode

Read More...

Sunday, July 26, 2020

Backup(Transferring and Synchronizing files) using python multiprocessing and rsync !

rsync(remote sync) is a utility for efficiently transferring and synchronizing files between a computer and an external storage

  1. Copy or sync files locally:

  2. rsync -zvh [Source-Files-Dir] [Destination]

  3. Copy or sync directory locally:

  4. rsync -zavh [Source-Files-Dir] [Destination]

  5. Copy files and directories recursively locally:

  6. rsync -zrvh [Source-Files-Dir] [Destination]  

  7. Sample  python code  script to do a backup using python...


  8. #!/usr/bin/env python

    import subprocess

    from multiprocessing import Pool


    from os import walk 


    src= "/home/user/data/"

    dest="/home/user/data/backup/"

    def backupData(dir):

        print("dir = "+ src+dir +" dest = " + dest+dir)

        subprocess.call(["rsync", "-arq", src+dir, dest+dir]) 


    dirList = []

    for (root, dirs, files) in walk(src):

        dirList.extend(dirs)

        break;

    print (dirList)

    p= Pool(len(dirList))

    p.map(backupData, dirList)


Read More...

Saturday, June 6, 2020

Cucumber/Gherkins with Java(kotlin) !

Cucumber is an opensource, Behavior-Driven Development (BDD) framework, where you execute your automated tests. You can pick up a regression suites for your automation test. We will mostly discuss about the the automation test written in Java/Kotlin in this tutorials.
Cucumber reads executable specifications written in plain text and validates that the software does what those specifications say.

What is Gherkins:
Gherkins is a business readable domain specific language. It is a set of grammar rules that makes plain text structured enough for Cucumber to understand.
Example :  Users are presented with Invalid Username/Password method when authentication fails
Scenarios: 
Cucumber uses Scenarios to defines the steps . You describe the Scenarios using Given, When, And and Then, But 
Example: 
Scenario: Users are presented with Invalid Username/Password method when authentication fails
Given User is in the login page
when User fills the invalid username or password
And User hit the submit button
Then User see the pop up screen saying Invalid Username/Password
When we define the  Scenario, we  can define multiple pre condition and multiple action and multiple expected outcomes.

We can collapse these two or more similar scenarios into a Scenario Outline as following
Scenario Outline: eating
  Given there are <start> cucumbers
  When I eat <eat> cucumbers
  Then I should have <left> cucumbers

  Examples:
    | start | eat | left |
    |    12 |   5 |    7 |
    |    20 |   5 |   15 |
(src: cucumber.io)
What is Feature and Feature File:
Feature can be defined as a standalone business functionality of a project. Feature file describes the testing needs for any features. A features file can contains one or many scenarios for you automated testings.In order the automatically detect the features by cucumber framework, you need to define it with .feature file extension. You will normally have a desperate feature file for each feature. 
(This post is still in progress--- keep visit us again)
    

Read More...

Tuesday, June 2, 2020

Updating the hosts file in MAC

echo '172.16.144.128 hdp hdp' | sudo tee -a /private/etc/hosts


Read More...

Saturday, May 16, 2020

Bash script to rename or move files from a directory !

Following is the bash script that renames a sets of file form the current directoy. In the following is just updating the extension.

#/bin/bash

for file in *.JPEG; do

        name=$(basename "$file" .JPEG)

        mv "$file" "$name.jpeg"

done




Read More...

Pages

 ©mytechtoday.com 2006-2010

 ©Mytechtoday

TOP