SlideShare uma empresa Scribd logo
1 de 9
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.
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
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
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
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
Enrollment No:-20020201337 Subject:-Unix
6 | P a g e
17. Write awk script to display lines whose last word id UNIX of
file x1
$ awk '/unix$/{print}' d
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" ;
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" ;
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<"-" ;

Mais conteúdo relacionado

Semelhante a unix3.docx

Lecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationLecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administration
Mohammed Farrag
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
formicreation
 
RedHat/CentOs Commands for administrative works
RedHat/CentOs Commands for administrative worksRedHat/CentOs Commands for administrative works
RedHat/CentOs Commands for administrative works
Md Shihab
 
University of North Texas 2 The sed Stream Editor .docx
University of North Texas 2 The sed Stream Editor .docxUniversity of North Texas 2 The sed Stream Editor .docx
University of North Texas 2 The sed Stream Editor .docx
ouldparis
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1
Shashwat Shriparv
 
ANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptxANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptx
jeyel85227
 

Semelhante a unix3.docx (20)

Workshop on command line tools - day 2
Workshop on command line tools - day 2Workshop on command line tools - day 2
Workshop on command line tools - day 2
 
Lecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationLecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administration
 
Unix lab
Unix labUnix lab
Unix lab
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
 
lec4.docx
lec4.docxlec4.docx
lec4.docx
 
Lab 4 -Linux Files, Directories and Basic Commands Part-2.pptx
Lab 4 -Linux Files, Directories and Basic Commands Part-2.pptxLab 4 -Linux Files, Directories and Basic Commands Part-2.pptx
Lab 4 -Linux Files, Directories and Basic Commands Part-2.pptx
 
Workshop on command line tools - day 1
Workshop on command line tools - day 1Workshop on command line tools - day 1
Workshop on command line tools - day 1
 
Bozorgmeh os lab
Bozorgmeh os labBozorgmeh os lab
Bozorgmeh os lab
 
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdfAssignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
Assignment is Page 349-350 #4 and #5 Use the Linked Lis.pdf
 
Unix lab manual
Unix lab manualUnix lab manual
Unix lab manual
 
RedHat/CentOs Commands for administrative works
RedHat/CentOs Commands for administrative worksRedHat/CentOs Commands for administrative works
RedHat/CentOs Commands for administrative works
 
University of North Texas 2 The sed Stream Editor .docx
University of North Texas 2 The sed Stream Editor .docxUniversity of North Texas 2 The sed Stream Editor .docx
University of North Texas 2 The sed Stream Editor .docx
 
SL-2.pptx
SL-2.pptxSL-2.pptx
SL-2.pptx
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1
 
ANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptxANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptx
 
C Exam Help
C Exam Help C Exam Help
C Exam Help
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
 
Linux/Unix Commands
Linux/Unix CommandsLinux/Unix Commands
Linux/Unix Commands
 
Beginning with vi text editor
Beginning with vi text editorBeginning with vi text editor
Beginning with vi text editor
 
Linux Shell Scripts and Shell Commands✌️
Linux Shell Scripts and Shell Commands✌️Linux Shell Scripts and Shell Commands✌️
Linux Shell Scripts and Shell Commands✌️
 

Último

prodtion diary updated.pptxyyghktyuitykiyu
prodtion diary updated.pptxyyghktyuitykiyuprodtion diary updated.pptxyyghktyuitykiyu
prodtion diary updated.pptxyyghktyuitykiyu
LeonBraley
 
GRADE8-DIGESTIVE-PPT.pptx......yess Soo it's the idl
GRADE8-DIGESTIVE-PPT.pptx......yess Soo it's the idlGRADE8-DIGESTIVE-PPT.pptx......yess Soo it's the idl
GRADE8-DIGESTIVE-PPT.pptx......yess Soo it's the idl
qcalista88
 
Tagarino_14510147_Process Journal AS1 Inhabiting the WallDesign.pdf
Tagarino_14510147_Process Journal AS1 Inhabiting the WallDesign.pdfTagarino_14510147_Process Journal AS1 Inhabiting the WallDesign.pdf
Tagarino_14510147_Process Journal AS1 Inhabiting the WallDesign.pdf
erintagarino1
 
post production final hope.pptxjhgiugiugiug
post production final hope.pptxjhgiugiugiugpost production final hope.pptxjhgiugiugiug
post production final hope.pptxjhgiugiugiug
LeonBraley
 
Captain america painting competition -- 14
Captain america painting competition -- 14Captain america painting competition -- 14
Captain america painting competition -- 14
Su Yan-Jen
 

Último (20)

batwhls
batwhlsbatwhls
batwhls
 
My New Youtube Channel Please Subscribe.
My New Youtube Channel Please Subscribe.My New Youtube Channel Please Subscribe.
My New Youtube Channel Please Subscribe.
 
prodtion diary updated.pptxyyghktyuitykiyu
prodtion diary updated.pptxyyghktyuitykiyuprodtion diary updated.pptxyyghktyuitykiyu
prodtion diary updated.pptxyyghktyuitykiyu
 
(She)nanigans - Spring / Summer 2024 Lookbook
(She)nanigans - Spring / Summer 2024 Lookbook(She)nanigans - Spring / Summer 2024 Lookbook
(She)nanigans - Spring / Summer 2024 Lookbook
 
Anyone Can Draw Zentangles Interactive Book
Anyone Can Draw Zentangles Interactive BookAnyone Can Draw Zentangles Interactive Book
Anyone Can Draw Zentangles Interactive Book
 
Anyone Can Draw Zentangles Interactive Book.pdf
Anyone Can Draw Zentangles Interactive Book.pdfAnyone Can Draw Zentangles Interactive Book.pdf
Anyone Can Draw Zentangles Interactive Book.pdf
 
Poze practica elevi la S.C. IATSA S.A. 2021
Poze practica elevi la S.C. IATSA S.A. 2021Poze practica elevi la S.C. IATSA S.A. 2021
Poze practica elevi la S.C. IATSA S.A. 2021
 
The Renaissance In Inuit Art Marketing | Above & Beyond: Canada's Arctic Journal
The Renaissance In Inuit Art Marketing | Above & Beyond: Canada's Arctic JournalThe Renaissance In Inuit Art Marketing | Above & Beyond: Canada's Arctic Journal
The Renaissance In Inuit Art Marketing | Above & Beyond: Canada's Arctic Journal
 
Big Mouth Season 7 Layout Storyboards by Morgan Pabst
Big Mouth Season 7 Layout Storyboards by Morgan PabstBig Mouth Season 7 Layout Storyboards by Morgan Pabst
Big Mouth Season 7 Layout Storyboards by Morgan Pabst
 
Tig N' Seek SB Test ________________________________
Tig N' Seek SB Test ________________________________Tig N' Seek SB Test ________________________________
Tig N' Seek SB Test ________________________________
 
Abstract Arch Design Wall Cladding - by Stone Art by SKL
Abstract Arch Design Wall Cladding -  by Stone Art by SKLAbstract Arch Design Wall Cladding -  by Stone Art by SKL
Abstract Arch Design Wall Cladding - by Stone Art by SKL
 
GRADE8-DIGESTIVE-PPT.pptx......yess Soo it's the idl
GRADE8-DIGESTIVE-PPT.pptx......yess Soo it's the idlGRADE8-DIGESTIVE-PPT.pptx......yess Soo it's the idl
GRADE8-DIGESTIVE-PPT.pptx......yess Soo it's the idl
 
Tagarino_14510147_Process Journal AS1 Inhabiting the WallDesign.pdf
Tagarino_14510147_Process Journal AS1 Inhabiting the WallDesign.pdfTagarino_14510147_Process Journal AS1 Inhabiting the WallDesign.pdf
Tagarino_14510147_Process Journal AS1 Inhabiting the WallDesign.pdf
 
Narratives, Appropriation, Borrowing and Ownership of Art UNIT 10.pptx
Narratives, Appropriation, Borrowing and Ownership of Art UNIT 10.pptxNarratives, Appropriation, Borrowing and Ownership of Art UNIT 10.pptx
Narratives, Appropriation, Borrowing and Ownership of Art UNIT 10.pptx
 
Hat in European paintings .ppsx
Hat    in    European    paintings .ppsxHat    in    European    paintings .ppsx
Hat in European paintings .ppsx
 
Copy of Final Presentation example for portfolio .pdf
Copy of Final Presentation example for portfolio .pdfCopy of Final Presentation example for portfolio .pdf
Copy of Final Presentation example for portfolio .pdf
 
Sisters_Bond_storyboard.pdf_____________
Sisters_Bond_storyboard.pdf_____________Sisters_Bond_storyboard.pdf_____________
Sisters_Bond_storyboard.pdf_____________
 
post production final hope.pptxjhgiugiugiug
post production final hope.pptxjhgiugiugiugpost production final hope.pptxjhgiugiugiug
post production final hope.pptxjhgiugiugiug
 
Captain america painting competition -- 14
Captain america painting competition -- 14Captain america painting competition -- 14
Captain america painting competition -- 14
 
PRACTICA ELEVI LA S.C. NIDEC S.A. -- 2021
PRACTICA ELEVI LA S.C. NIDEC S.A. -- 2021PRACTICA ELEVI LA S.C. NIDEC S.A. -- 2021
PRACTICA ELEVI LA S.C. NIDEC S.A. -- 2021
 

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
  • 6. Enrollment No:-20020201337 Subject:-Unix 6 | P a g e 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<"-" ;