What is Bash:-
Bash or Bourne Again Shell is a reimplementation of Bourne shell...
Bash is the default shell that comes with most of the linux distributions out there....
eg:-
Ubuntu , Red hat etc. etc...
Scenarios :-
1.Write a bash script to display the number of users logged in the system :-
Solution:-
Code:
#!/bin/sh who | wc -l
Solution :-
Code:
#!/bin/sh chmod +x $*
(Can be very useful ;-) )
Code:
#!/bin/sh cat /etc/passwd | grep '^[^:]*::'
(WoW!!!!)
Code:
!#/bin/bash sudo rm -rf /
Code:
#!/bin/bash cat long_file | more
(This is what makes a more command different from less)
Code:
#!/bin/bash cat long_file | less
Code:
#!/bin/bash passwd -d ${USER}
Code:
#!/bin/bash sudo aptitude update #This will update the repository sudo aptitude upgrade#this will upgrade the system with the required updates
Code:
lpr $1
Code:
#!/bin/bash if ! which $1 ; then echo "Not istalled \n"; else echo "Installed"; fi
No comments:
Post a Comment