Professional Documents
Culture Documents
SHELL SCRIPTING
> (redirect) :- it use to use the output in other command.
eg: echo "hello there" > new.txt
output:
cat new.txt
hello there
>> (append) : work like redirect but add data to existing file without overriding.
echo "hello there sachin" > new.txt
output:
cat new.txt
hello there
hello there sachin
syntax:-
find (location were to find) -type d
eg:-
find a -type d
**in output it return the path of all the directories present inside that location.
grep :- use to grab the word from any file.this return the word if the given word
appear in it.
syntax :-
grap (word) (file name)
**this is a case sensitive.
AWK
awk :-works for the table related data.
syntax:
awk '{print}' filename or awk '{print $0}' filename: to print complete data of the file.
awk '{print $1 $2}' filename : to concatinate data of colume 1 and 2 and print.
awk '{print $1,$2}' filename : to print data of coloumn 1 and 2 without concatination.
awk 'NR==row number {print $0}' filename: to print perticular row.
awk '{print $NR}' filename : to print thr last row.
awk '{print $(NR-i)}' filename: to print perticular row from the last.
awk 'NR==i,NR==j{print $0}' filename :from i to j is the limit of row to print.
awk 'NR==i;NR==j{print $0}' filename : only print i and j row.
case 2 :- let the data is written in continuous format with a PERTICULAR SEPRATOR to print
according to seprator :
syntax:
awk -F "seprator" '{print }' filename:
for all above case operation just add :- -F "seprator"
case 3 :- when we have to find a perticular word in the table.
syntax :
awk '/word which want to find/{print}' filename : all data will display which have that word in
row.
awk '/word which want to find| second word/{print}' filename :- | or operator
awk '$i~/word which want to find/{print}' filename : for perticular row .
**
awk '{print length($i)}' filename :-length of perticular columne of each row.
SUDO
if we want to edit a file which have not the permission to edit. so here we have
two way
i)change the owner
ii)sudo :-command before any command.to over rite the permission.
UNIX Login:
if we declare a variable in terminal and after re opening of the terminal we are
not able to access the variable value
because it is temprory in the terminal .
to use the value of that variable we have to create that in the ".bashrc" file of the
linux which run very first just
after the opening of the terminal.
** when you want to know the place were command is stored use which command
synatax
which command_name
eg :-
which ls
which pwd