Saturday, 10 December 2016

Use of paste command

Paste : This command is used to join files horizontally by delimiter.
                                       Syntax:$paste <filename1> <filename2>....<filenamen>
default delimiter is tab.
Ex:
$paste employees departments
Ex:
$paste -d ":" employees departments
Ex :
$paste employees salary departments
Ex:
$paste -d ":" employees salary departments


Friday, 9 December 2016

Use of cut command

Cut : This command is used to extract or divide specific fields and characters from a given file based on delimiters.
                           Syntax:$cut (fields) or (delimiter) or (character) <filename>
Ex:
$cut -f 1,3 jobs
It displays 1st and 3rd fields from jobs file.
-f means field by field.
Note: Default delimiter is tab.
When default delimiter is tab that's why no need to mention it,but if delimiter is other than tab we have to mention that delimiter.

Ex:
$cut -f 2-4 jobs
It displays 2nd fields to 4th fields.
Ex:
$cut -f 2- jobs
It displays 2nd field to last field from jobs file.
Ex:
$cut -d "," -f 1,3 countries
It displays 1st and 3rd fields from countries file.
Here in countries file all fields separated by comm delimiter.So, we have to mention it,

Ex:
$cut -c 1-10 jobs
It displays every row 1st character to 10th character from jobs file.

Ex:
$cut 1-5,10-15 jobs
It displays every row 1st character to 5th character and from 10th character to 15th character.

Friday, 2 December 2016

Use of wild card characters

Wild card characters

a) * : It is used to matches 0 or more characters
b) ? : It is used to matches any single character.
c) [ ] : It is used to matches any single character in the given list.
d) [-] : It is used to matches any single character in the given range.

Ex:
i)$ls f*
ii)$ls *c
iii)$ls f?
iv)$ls f????
v)$ls [abcdef]*
vi)$ls [a-z]*

vii)$rm *
viii)$rm -i*
ix)rm a*



Thursday, 1 December 2016

Use of date command

To print date

a)date : This command is used to represent date.
                                         Syntax:$date

b)date +%d : To display day in number from date.
c)date +%a : To display weekday in word from date.
d)date +%y : To display year in number from date.

Ex:
$date +%d-%b-%y



Use of history command

history : This command is used to display the previous commands which is executed  on the terminal.
                                          Syntax:$history

history -c : This command is used to to clear the history from the terminal.
                                          Syntax:$history -c

After running history -c command history is cleared.We can check it by using history command.

Use of ls command

Viewing list of files

a)ls : This command is used to display current directory all files and directories in the ascending order based on ASCII values.By default files and directories display order is ascending.
                                  Syntax:$ls

b)ls -r : This command is used to display current directory all files and directories in the descending order or reverse order.
                                  Syntax:$ls -r

c)ls -R : This command is used to display current directory all files and directories recursively.
                                  Syntax:$ls -R

d)ls -a : This command is used to display current directory all files and directories including hidden files.
                                  Syntax:$ls -a

e)ls -u : This command is used to display current directory all files and directories based on when they were last used.
                                  Syntax:$ls -u

f)ls -t : This command is used to display current directory all files and directories based on date and of creation.
                                  Syntax:$ls -t

g)ls -l : This command is used to display list of all files in long list format.
                                  Syntax:$ls -l
Here
d and - represent file type.
rwrwxr-x and rw-rw-r represents file permissions
3 and 1 represents Number of links.
practice and practice represents owner name.
practice and practice represents group name.
4096,0,46,10 represents size in bytes.
Dec 1,Nov 30 represents date.
18:52,23:51 represents time.
ABC,f1,f2 are filename.

h)ls -lr : This command is used to display current directory all files and directories in the descending order or reverse order in long list format.
                                   Syntax:$ls -lr
i)ls -lR : This command is used to display current directory all files and directories recursively in long list format.
                                   Syntax:$ls -lR

j)ls -la : This command is used to display current directory all files and directories including hidden files in long list format.
                                   Syntax:$ls -la

k)ls -lu : This command is used to display current directory all files and directories based on when they were last used in long list format.
                                   Syntax:$ls -lu
l)ls -lt : This command is used to display current directory all files and directories based on date and of creation in long list format.
                                  Syntax:$ls -lt