Reading view

There are new articles available, click to refresh the page.

MongoDb Queries

  1. Group By Query: grouped using ChassisNo
    [
    {“$group” : { “_id”: “$chassisNo”, “count”: { “$sum”: 1 } } },
    {“$match”: {“_id” :{ “$ne” : null } , “count” : {“$gt”: 1} } },
    {“$project”: {“name” : “$_id”, “_id” : 0} }
    ]

Grouped using $group by ChassisNo,

In match we specify id shouldn’t be null and we take the group items which is more than one in count(“count” : {“$gt”: 1} )

In Projection, we assign it to the name key and _id which is default field we don’t need that so we give _id:0

2. Select one field in MongoDb: ==> {}, {invoiceNo:1, _id:0}
db.getCollection(‘t_frwrdr_invc’).find({}, {invoiceNo:1, _id:0}).sort({ “_id” : -1})

{}-> match condition

{invoiceNo:1, _id:0} -> Result set extraction.

InvoiceNo only printed in the result.

_id : which is common for all the documents. So when we give _id:0 then it will not be shown in document. if we have given _id:1 then it will be shown in the result set.

MongoDb Queries

  1. Group By Query: grouped using ChassisNo
    [
    {“$group” : { “_id”: “$chassisNo”, “count”: { “$sum”: 1 } } },
    {“$match”: {“_id” :{ “$ne” : null } , “count” : {“$gt”: 1} } },
    {“$project”: {“name” : “$_id”, “_id” : 0} }
    ]

Grouped using $group by ChassisNo,

In match we specify id shouldn’t be null and we take the group items which is more than one in count(“count” : {“$gt”: 1} )

In Projection, we assign it to the name key and _id which is default field we don’t need that so we give _id:0

2. Select one field in MongoDb: ==> {}, {invoiceNo:1, _id:0}
db.getCollection(‘t_frwrdr_invc’).find({}, {invoiceNo:1, _id:0}).sort({ “_id” : -1})

{}-> match condition

{invoiceNo:1, _id:0} -> Result set extraction.

InvoiceNo only printed in the result.

_id : which is common for all the documents. So when we give _id:0 then it will not be shown in document. if we have given _id:1 then it will be shown in the result set.

Day 6

Join

It joins the line by line by matching fields.
-> join test1.txt test2.txt
When the order is different like 1st column contains number in one file and letters in another file then we need to give the column and file name.
-> join -1(denotes file name) 2(denotes column name ) -2(denotes file name) 1(denotes columnname) test1.text test2.text

File

File commands gives file type of a file example like PDF, image, ASCII Text
-> file sample.text => returns ASCII Text
File * -> gives all file type of all files present.

Touch

1.Creates a new file.
touch test{1..5-}.text => generates 50 files as test1,test2.text ..etc..
Also, when we run this command it throws msg if don’t have permmission to create file in that directory

  1. Used to change the time stamp of the file
    -> touch -d tomorrow sample.text => it changes time stamp of this file
    -> touch -r(reference) test1.txt test2.txt => it take the test1.txt file timestamp and uses for test2.

Cal

Calnder used to print the current year month.
cal -y 1995 => prints the calender for the mentioned year.

Rev

Reverse command writes the characters is reverse order.
rev sample.txt

Redirection

it produces the Output (>)
it takes the input(<) -> wc < sample.text > sample2.text => wc count of sample text is written to sample2.txt
it appends the text (>>)

Tee

It read from standard output and writes to standard input.
-> df | tee new.text => df output is being return to new file

Grep

Search the line with matches the input pattern.
-> grep “linux” log.text
-> grep -i(removing case sensitive) “linux” log.txt
-> grep -c -i “linux” log.txt => gives the count

Day 6

Join

It joins the line by line by matching fields.
-> join test1.txt test2.txt
When the order is different like 1st column contains number in one file and letters in another file then we need to give the column and file name.
-> join -1(denotes file name) 2(denotes column name ) -2(denotes file name) 1(denotes columnname) test1.text test2.text

File

File commands gives file type of a file example like PDF, image, ASCII Text
-> file sample.text => returns ASCII Text
File * -> gives all file type of all files present.

Touch

1.Creates a new file.
touch test{1..5-}.text => generates 50 files as test1,test2.text ..etc..
Also, when we run this command it throws msg if don’t have permmission to create file in that directory

  1. Used to change the time stamp of the file
    -> touch -d tomorrow sample.text => it changes time stamp of this file
    -> touch -r(reference) test1.txt test2.txt => it take the test1.txt file timestamp and uses for test2.

Cal

Calnder used to print the current year month.
cal -y 1995 => prints the calender for the mentioned year.

Rev

Reverse command writes the characters is reverse order.
rev sample.txt

Redirection

it produces the Output (>)
it takes the input(<) -> wc < sample.text > sample2.text => wc count of sample text is written to sample2.txt
it appends the text (>>)

Tee

It read from standard output and writes to standard input.
-> df | tee new.text => df output is being return to new file

Grep

Search the line with matches the input pattern.
-> grep “linux” log.text
-> grep -i(removing case sensitive) “linux” log.txt
-> grep -c -i “linux” log.txt => gives the count

Day-3

Grep Commands

grep commands used to find lines with matching patten
cat sample.text | grep Hi -> it returns all the lines which has Hi.

Vim Editor

It is an editor.
press ‘i’ to insert
to save, esc+:wq!
to quit , esc+q!

Find Commands

find .(denotes present working directory) -type f(denotes file name) -sample.text(file name)
it is used find the particular file

Environment Commands

env -> gives all the environment variables
export java_home(variable) = /jdk18(value)

df Commands

df -> returns the usage of our file system
df -h -> returns it in human readable format

Less Commands

less sample.text it gives the file, with page by page

Sort Commands

sort -u sample.text -> removes duplicate elements
we can use sort with cat commands
sort test1.text > sorted_test1.text -> sorts and saves the data in new file sorted_test1.text

Uniq Commands

uniq sample.text -> shows only uniquq names removes duplicate

Cut Commands

cat sample.text | cut -c-5 -> it cuts the first 5 characters and prints it

Day-3

Grep Commands

grep commands used to find lines with matching patten
cat sample.text | grep Hi -> it returns all the lines which has Hi.

Vim Editor

It is an editor.
press ‘i’ to insert
to save, esc+:wq!
to quit , esc+q!

Find Commands

find .(denotes present working directory) -type f(denotes file name) -sample.text(file name)
it is used find the particular file

Environment Commands

env -> gives all the environment variables
export java_home(variable) = /jdk18(value)

df Commands

df -> returns the usage of our file system
df -h -> returns it in human readable format

Less Commands

less sample.text it gives the file, with page by page

Sort Commands

sort -u sample.text -> removes duplicate elements
we can use sort with cat commands
sort test1.text > sorted_test1.text -> sorts and saves the data in new file sorted_test1.text

Uniq Commands

uniq sample.text -> shows only uniquq names removes duplicate

Cut Commands

cat sample.text | cut -c-5 -> it cuts the first 5 characters and prints it

Day -2 in Commands

Uname Commands

uname -> it gives system information
uname -a -> it gives all system information
uname -s -> gives info about Kernel
uname -r -> shows release information

Uptime Commands

uptime -> gives when the system being activated
uptime -p(pretty ) -> it tells the time exactly
uptime -s -> it tells the exact time frame

Make Directory Commands

Below commands are used to create directory.

pwd -> Tells the Present working Directory
mkdir testdir(directoryname) -> creates the directory
mkdir -v testdir -> v means verbose , it gives additional info about the directory.
mkdir {dir1,dir2,dir3} -> creates multiple directories

Remove Directory
rmdir -> It removes only when the directory is empty’

CD Commands

cd -> changes to Home directory
cd test1 -> returns to specified directory
cd .. -> one step back

Locate Commands

we may compelled to use sudo updatedb in order to work this command.
locate sample.text -> it will locate the file

WHO Commands

who -> tells username, ip, time
who -r -> it gives the run level data
who -b -> tells the boot time

WC -> Word Count Commands

wc test1.txt -> gives no of lines, no of words, size of the file ( 1, 10, 15)

Copy Commands

cp test1.txt test2.txt copies content from test1 to test2

Move Commands

It is used to rename the file name.
mv java.text java1.text -> file name renamed to java1.text
mv java1.text learn(destination directory) -> it moves the file to destination directory

Day -2 in Commands

Uname Commands

uname -> it gives system information
uname -a -> it gives all system information
uname -s -> gives info about Kernel
uname -r -> shows release information

Uptime Commands

uptime -> gives when the system being activated
uptime -p(pretty ) -> it tells the time exactly
uptime -s -> it tells the exact time frame

Make Directory Commands

Below commands are used to create directory.

pwd -> Tells the Present working Directory
mkdir testdir(directoryname) -> creates the directory
mkdir -v testdir -> v means verbose , it gives additional info about the directory.
mkdir {dir1,dir2,dir3} -> creates multiple directories

Remove Directory
rmdir -> It removes only when the directory is empty’

CD Commands

cd -> changes to Home directory
cd test1 -> returns to specified directory
cd .. -> one step back

Locate Commands

we may compelled to use sudo updatedb in order to work this command.
locate sample.text -> it will locate the file

WHO Commands

who -> tells username, ip, time
who -r -> it gives the run level data
who -b -> tells the boot time

WC -> Word Count Commands

wc test1.txt -> gives no of lines, no of words, size of the file ( 1, 10, 15)

Copy Commands

cp test1.txt test2.txt copies content from test1 to test2

Move Commands

It is used to rename the file name.
mv java.text java1.text -> file name renamed to java1.text
mv java1.text learn(destination directory) -> it moves the file to destination directory

Day – 1 in Commands Practice

Today Learned below commands.

List Commands

ls -> it listed out all the files
ls -l -> it gave long listing items
ls -lh -> it returns items with human readable file size
ls -lS -> it sorted out the files
ls -lSh -> it sorted the files also it returns file with human readable format
ls -R -> returned all the files in the directory

whoami -> shows the current user
hostname -> shows the hostname
hostname -I -> shows the IP address of the user

Date Commands

date -> displayed current date
date –date=”tomorrow” -> prints the tomorrow date
date –date=”3 years ago” -> prints the date 3 years ago.

CAT Commands : Concatenate commands

cat > test1.text -> creates a new file
cat test1.text | less -> show the file in page fize
q -> to quit

ECHO Commands

echo “Hello world” -> it usually prints the data.

History Commands

history -> it displays the last 1000 commands executed in our machine. we can increase the limit
history 10 -> executes last 10 commands
history | head -> shows first 10 commands
history | tail -> last 10 commands
history !1000(event) -> executed the specified event command.

Remove command

rm -i test1.text -> it asks user permission whether to delete this or not
rm test1.text -> removes the files
rm * text -> removes all the files which are text file type.

Manual command

man ls -> shows all the information about ls command
man date -> displayes all the info about date command
z -> to down the page.
w -> to go up in the page.

Day – 1 in Commands Practice

Today Learned below commands.

List Commands

ls -> it listed out all the files
ls -l -> it gave long listing items
ls -lh -> it returns items with human readable file size
ls -lS -> it sorted out the files
ls -lSh -> it sorted the files also it returns file with human readable format
ls -R -> returned all the files in the directory

whoami -> shows the current user
hostname -> shows the hostname
hostname -I -> shows the IP address of the user

Date Commands

date -> displayed current date
date –date=”tomorrow” -> prints the tomorrow date
date –date=”3 years ago” -> prints the date 3 years ago.

CAT Commands : Concatenate commands

cat > test1.text -> creates a new file
cat test1.text | less -> show the file in page fize
q -> to quit

ECHO Commands

echo “Hello world” -> it usually prints the data.

History Commands

history -> it displays the last 1000 commands executed in our machine. we can increase the limit
history 10 -> executes last 10 commands
history | head -> shows first 10 commands
history | tail -> last 10 commands
history !1000(event) -> executed the specified event command.

Remove command

rm -i test1.text -> it asks user permission whether to delete this or not
rm test1.text -> removes the files
rm * text -> removes all the files which are text file type.

Manual command

man ls -> shows all the information about ls command
man date -> displayes all the info about date command
z -> to down the page.
w -> to go up in the page.

Linux Learning

Linux Learning

Learned the use of Mobaxterm, it is like putty..
  Connected my Ubuntu machine using mobaxterm.
 Tried below commands.

   sudo apt update : it would install all the packages.
   pwd  : shows the current working directory
  whoami : shows the current



❌