Skip to main content

27/06/2019_Week1_Thursday

Objective is to create a bash file to read a given file and output the word count

Read Lines From An File Input


    
        input="path_to_the _text_file"
        while IFS= read -r line
        do
        echo "$line"
        done < "$input"

        if [[ $str = *main* ]]; then
          echo "Yes"
        fi
     
   

Replace a string with an substring

        
        #!/bin/bash

        firstString="I love Suzi and Marry"
        secondString="Sara"
        echo "${firstString/Suzi/$secondString}"
        # prints 'I love Sara and Marry'
    
    
REF : www.tutorialkart.com/bash-shell-scripting/bash-if/#Example-1

        #!/bin/bash

        count=0
        input=~/Documents/sample-text.txt
        while read -r line;   #reading lines in the while loop
        do
        for word in $line;  #for loop to count words in a line
        do
        read -ra ARR <<< "$word"   #will read $word to an array named ARR
        for i in "${ARR[@]}"; do # access each element  of array
        echo "$i"             #to see what are the elements of array
        count=$((count+1))  #keeps the count of the words seperated.
        done
        done
        done <$input
        echo "c= $count "   #displays the final 

OUTPUT :

Comments

Popular posts from this blog

git

git is a useful platform for software project management where it gives you speed and efficiency when handling larger or smaller projects. git keeps track of your workflow and editing ,branching , merging and debugging the code is granted to different users. git config git config –global user.name “[name]” git config –global user.email “[email address]” git init  initiates git git clone clones git project to the current directory git add adding files to the staging area. git commit git commit -m “[ Type in the commit message]” records the files in the staging area permanently in the history git diff shows the files differences which are not yet staged git diff –staged This command shows the differences between the files in the staging area and the latest version present. git diff [first branch] [second branch] git commit -a This command commits any files you’ve added with the git add command and also commits any files you’ve changed since ...

Research Project: AutoComplete Business Places Search Form

RESEARCH PROJECT  AUTOCOMPLETE BUSINESS PLACES SUGGESTING DROP DOWN LIST Date: 09/08/2019 The research is on how to use google powered auto suggest input form to search businesses and show its address too. And a thread has been found on auto completing drop down list on google maps platform. A look alike project on autocomplete for addresses and search terms is there in google Maps Platform for developers. The Steps taken. First of all you need the example code in your PC. Create a test Project in google Console. Autofill-inputbox Then the relevant API enabled in That project console. In this case the "Places API" An API key for a particular project. Tried running with the acquired API in the code and putting the file on tomcat server as a jsp file. Still the billing_error comes. The problem was maps API was not enabled. So that the page didn't load. But when it's enabled the website worked for a several seconds. Returning the ...

Admin-web project

Started working on an actual project first have to create a remote branch  adrin@adrian-pc:~/projects/admin-web/admin-web$ git pull  From gitlablive.hsenidmobile.com:apptizer/admin-web  * [new branch]      feature/S11-APT-609-download-android-app-bundle -> origin/feature/S11-APT-609-download-android-app-bundle Already up-to-date. adrin@adrian-pc:~/projects/admin-web/admin-web$ git checkout -b feature/S11-APT-610-product-category-visibility-switch-for-webstore Switched to a new branch 'feature/S11-APT-610-product-category-visibility-switch-for-webstore' adrin@adrian-pc:~/projects/admin-web/admin-web$ git push --set-upstream origin feature/S11-APT-610-product-category-visibility-switch-for-webstore  Total 0 (delta 0), reused 0 (delta 0) To git@gitlablive.hsenidmobile.com:apptizer/admin-web.git  * [new branch]      feature/S11-APT-610-product-category-visibility-switch-for-webstore -> feature/S11-APT-610-product-ca...