(NEHA) Call Girls Mumbai Call Now 8250077686 Mumbai Escorts 24x7
unix3.docx
1. Enrollment No:-20020201337 Subject:-Unix
1 | P a g e
1. Write a command to delete all special character from the file
x1
$ sed ‘s/[#$@*%]//g’ d
2. To extract all username and their home directory from
/etc/passwd file
$ grep -oP '^[^:]+|.*:K[^:]+(?=:[^:]+)' /etc/passwd | perl -pe 's/n/ : / if $.%2'
3. . Count frequency of users who are logged-in from more than one terminal. $ who |
wc-l
4. Delete all leading and trailing spaces in all line of file f1.
2. Enrollment No:-20020201337 Subject:-Unix
2 | P a g e
$ sed 's/^[ t]*//' d
5. Display string in uppercase.
$ awk '{print toupper($0)}' d
6. Write a command to locate lines that begin and end with a
dot(.) ans containing anything between them
$ grep "^..*.$" d
$ sed -n '/^..*.$/p' d
7. Write a command to remove duplicate lines form a file
$ sed -n 's/unix/linux/p' d
8. Replace the word UNIX with Linux in between 5th to 10th
lines including both.
$ sed '5,10 s/unix/linux/' d
3. Enrollment No:-20020201337 Subject:-Unix
3 | P a g e
9. Remove all leading space from a file x1.
$ sed -ne 's/^[ t]*//p' d
10. To display lines of file f1 this contains pattern as user1 or
user2 or user3
$ grep -e 'user1' -e 'user2' -e 'user3' d
11. . Display a line of file f1 which contains exact 8 characters
$ grep '^.{8}$' d
4. Enrollment No:-20020201337 Subject:-Unix
4 | P a g e
12. Count all empty lines (consist of only new line character) of
file f2
$ grep -c '^$' d
10. To display lines of file f1 this contains pattern as user1 or
user2 or user3
$ grep -e 'user1' -e 'user2' -e 'user3' d
11. . Display a line of file f1 which contains exact 8 characters
$ grep '^.{8}$' d
5. Enrollment No:-20020201337 Subject:-Unix
5 | P a g e
12. Count all empty lines (consist of only new line character) of
file f2
$ grep -c '^$' d
17. Write awk script to display lines whose last word id UNIX of
file x1
$ awk '/unix$/{print}' d
7. Enrollment No:-20020201337 Subject:-Unix
7 | P a g e
a. Find Greatest No.
b. Palindrome No.
BEGIN{ print"main menu" ;
print"1.factorial of number" ;
print"2.Greater number" ;
print"3.palindrome of
number" ; print "Enter ur
choice" ; getline ch<"-" ;
print ch ;
if(ch==1)
{
print "enter the number" ;
getline tmp<"-" ;
c=1 ;
while(tmp != 0)
{
c=c*tmp ;
tmp-- ;
}
print c ;
}
if(ch==2)
{
print "enter first number" ;
getline a1<"-" ; print
"enter second number" ;
getline a2<"-" ; print
"enter third number" ;
8. Enrollment No:-20020201337 Subject:-Unix
8 | P a g e
getline a3<"-" ; if(a1>a2
&& a1>a3) print "first
number is greater " ;
if(a2>a1 && a2>a3)
print "second number is greater " ;
if(a3>a1 && a3>a2)
print "third number is greater " ;
}
if(ch==3)
{
print "enter the number" ;
getline tmp<"-" ;
a. Find Greatest No.
b. Palindrome No.
BEGIN{ print"main menu" ;
print"1.factorial of number" ;
print"2.Greater number" ;
print"3.palindrome of
number" ; print "Enter ur
choice" ; getline ch<"-" ;
print ch ;
if(ch==1)
{
print "enter the number" ;
getline tmp<"-" ;
c=1 ;
while(tmp != 0)
{
c=c*tmp ;
tmp-- ;
}
print c ;
}
if(ch==2)
{
print "enter first number" ;
getline a1<"-" ; print
"enter second number" ;
getline a2<"-" ; print
"enter third number" ;
9. Enrollment No:-20020201337 Subject:-Unix
9 | P a g e
getline a3<"-" ; if(a1>a2
&& a1>a3) print "first
number is greater " ;
if(a2>a1 && a2>a3)
print "second number is greater " ;
if(a3>a1 && a3>a2)
print "third number is greater " ;
}
if(ch==3)
{
print "enter the number" ;
getline tmp<"-" ;