SlideShare a Scribd company logo
1 of 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<"-" ;

More Related Content

Similar to unix3.docx

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 2Leandro Lima
 
Lecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationLecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationMohammed Farrag
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdfsrxerox
 
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.pptxCiceer Ghimirey
 
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 1Leandro Lima
 
Bozorgmeh os lab
Bozorgmeh os labBozorgmeh os lab
Bozorgmeh os labFS Karimi
 
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.pdfformicreation
 
RedHat/CentOs Commands for administrative works
RedHat/CentOs Commands for administrative worksRedHat/CentOs Commands for administrative works
RedHat/CentOs Commands for administrative worksMd 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 .docxouldparis
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1Shashwat Shriparv
 
ANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptxANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptxjeyel85227
 
Beginning with vi text editor
Beginning with vi text editorBeginning with vi text editor
Beginning with vi text editorJose Pla
 
Linux Shell Scripts and Shell Commands✌️
Linux Shell Scripts and Shell Commands✌️Linux Shell Scripts and Shell Commands✌️
Linux Shell Scripts and Shell Commands✌️Nazmul Hyder
 

Similar to 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✌️
 

Recently uploaded

Lucknow 💋 best call girls in Lucknow (Adult Only) 8923113531 Escort Service ...
Lucknow 💋 best call girls in Lucknow  (Adult Only) 8923113531 Escort Service ...Lucknow 💋 best call girls in Lucknow  (Adult Only) 8923113531 Escort Service ...
Lucknow 💋 best call girls in Lucknow (Adult Only) 8923113531 Escort Service ...anilsa9823
 
The First Date by Daniel Johnson (Inspired By True Events)
The First Date by Daniel Johnson (Inspired By True Events)The First Date by Daniel Johnson (Inspired By True Events)
The First Date by Daniel Johnson (Inspired By True Events)thephillipta
 
Lucknow 💋 Russian Call Girls Sushant Golf City - 450+ Call Girl Cash Payment ...
Lucknow 💋 Russian Call Girls Sushant Golf City - 450+ Call Girl Cash Payment ...Lucknow 💋 Russian Call Girls Sushant Golf City - 450+ Call Girl Cash Payment ...
Lucknow 💋 Russian Call Girls Sushant Golf City - 450+ Call Girl Cash Payment ...anilsa9823
 
GENUINE EscoRtS,Call Girls IN South Delhi Locanto TM''| +91-8377087607
GENUINE EscoRtS,Call Girls IN South Delhi Locanto TM''| +91-8377087607GENUINE EscoRtS,Call Girls IN South Delhi Locanto TM''| +91-8377087607
GENUINE EscoRtS,Call Girls IN South Delhi Locanto TM''| +91-8377087607dollysharma2066
 
Lucknow 💋 Call Girl in Lucknow Phone No 8923113531 Elite Escort Service Avail...
Lucknow 💋 Call Girl in Lucknow Phone No 8923113531 Elite Escort Service Avail...Lucknow 💋 Call Girl in Lucknow Phone No 8923113531 Elite Escort Service Avail...
Lucknow 💋 Call Girl in Lucknow Phone No 8923113531 Elite Escort Service Avail...anilsa9823
 
Lucknow 💋 Escorts Service Lucknow Phone No 8923113531 Elite Escort Service Av...
Lucknow 💋 Escorts Service Lucknow Phone No 8923113531 Elite Escort Service Av...Lucknow 💋 Escorts Service Lucknow Phone No 8923113531 Elite Escort Service Av...
Lucknow 💋 Escorts Service Lucknow Phone No 8923113531 Elite Escort Service Av...anilsa9823
 
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...akbard9823
 
Admirable # 00971529501107 # Call Girls at dubai by Dubai Call Girl
Admirable # 00971529501107 # Call Girls at dubai by Dubai Call GirlAdmirable # 00971529501107 # Call Girls at dubai by Dubai Call Girl
Admirable # 00971529501107 # Call Girls at dubai by Dubai Call Girlhome
 
Lucknow 💋 Call Girls in Lucknow ₹7.5k Pick Up & Drop With Cash Payment 892311...
Lucknow 💋 Call Girls in Lucknow ₹7.5k Pick Up & Drop With Cash Payment 892311...Lucknow 💋 Call Girls in Lucknow ₹7.5k Pick Up & Drop With Cash Payment 892311...
Lucknow 💋 Call Girls in Lucknow ₹7.5k Pick Up & Drop With Cash Payment 892311...anilsa9823
 
Lucknow 💋 Call Girl in Lucknow 10k @ I'm VIP Independent Escorts Girls 892311...
Lucknow 💋 Call Girl in Lucknow 10k @ I'm VIP Independent Escorts Girls 892311...Lucknow 💋 Call Girl in Lucknow 10k @ I'm VIP Independent Escorts Girls 892311...
Lucknow 💋 Call Girl in Lucknow 10k @ I'm VIP Independent Escorts Girls 892311...anilsa9823
 
Jeremy Casson - Top Tips for Pottery Wheel Throwing
Jeremy Casson - Top Tips for Pottery Wheel ThrowingJeremy Casson - Top Tips for Pottery Wheel Throwing
Jeremy Casson - Top Tips for Pottery Wheel ThrowingJeremy Casson
 
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...anilsa9823
 
RAK Call Girls Service # 971559085003 # Call Girl Service In RAK
RAK Call Girls Service # 971559085003 # Call Girl Service In RAKRAK Call Girls Service # 971559085003 # Call Girl Service In RAK
RAK Call Girls Service # 971559085003 # Call Girl Service In RAKedwardsara83
 
Lucknow 💋 Russian Call Girls Lucknow | Whatsapp No 8923113531 VIP Escorts Ser...
Lucknow 💋 Russian Call Girls Lucknow | Whatsapp No 8923113531 VIP Escorts Ser...Lucknow 💋 Russian Call Girls Lucknow | Whatsapp No 8923113531 VIP Escorts Ser...
Lucknow 💋 Russian Call Girls Lucknow | Whatsapp No 8923113531 VIP Escorts Ser...anilsa9823
 
Call girls in Kanpur - 9761072362 with room service
Call girls in Kanpur - 9761072362 with room serviceCall girls in Kanpur - 9761072362 with room service
Call girls in Kanpur - 9761072362 with room servicediscovermytutordmt
 
Jeremy Casson - How Painstaking Restoration Has Revealed the Beauty of an Imp...
Jeremy Casson - How Painstaking Restoration Has Revealed the Beauty of an Imp...Jeremy Casson - How Painstaking Restoration Has Revealed the Beauty of an Imp...
Jeremy Casson - How Painstaking Restoration Has Revealed the Beauty of an Imp...Jeremy Casson
 
Lucknow 💋 Escort Service in Lucknow (Adult Only) 8923113531 Escort Service 2...
Lucknow 💋 Escort Service in Lucknow  (Adult Only) 8923113531 Escort Service 2...Lucknow 💋 Escort Service in Lucknow  (Adult Only) 8923113531 Escort Service 2...
Lucknow 💋 Escort Service in Lucknow (Adult Only) 8923113531 Escort Service 2...anilsa9823
 

Recently uploaded (20)

Lucknow 💋 best call girls in Lucknow (Adult Only) 8923113531 Escort Service ...
Lucknow 💋 best call girls in Lucknow  (Adult Only) 8923113531 Escort Service ...Lucknow 💋 best call girls in Lucknow  (Adult Only) 8923113531 Escort Service ...
Lucknow 💋 best call girls in Lucknow (Adult Only) 8923113531 Escort Service ...
 
The First Date by Daniel Johnson (Inspired By True Events)
The First Date by Daniel Johnson (Inspired By True Events)The First Date by Daniel Johnson (Inspired By True Events)
The First Date by Daniel Johnson (Inspired By True Events)
 
Lucknow 💋 Russian Call Girls Sushant Golf City - 450+ Call Girl Cash Payment ...
Lucknow 💋 Russian Call Girls Sushant Golf City - 450+ Call Girl Cash Payment ...Lucknow 💋 Russian Call Girls Sushant Golf City - 450+ Call Girl Cash Payment ...
Lucknow 💋 Russian Call Girls Sushant Golf City - 450+ Call Girl Cash Payment ...
 
GENUINE EscoRtS,Call Girls IN South Delhi Locanto TM''| +91-8377087607
GENUINE EscoRtS,Call Girls IN South Delhi Locanto TM''| +91-8377087607GENUINE EscoRtS,Call Girls IN South Delhi Locanto TM''| +91-8377087607
GENUINE EscoRtS,Call Girls IN South Delhi Locanto TM''| +91-8377087607
 
Lucknow 💋 Call Girl in Lucknow Phone No 8923113531 Elite Escort Service Avail...
Lucknow 💋 Call Girl in Lucknow Phone No 8923113531 Elite Escort Service Avail...Lucknow 💋 Call Girl in Lucknow Phone No 8923113531 Elite Escort Service Avail...
Lucknow 💋 Call Girl in Lucknow Phone No 8923113531 Elite Escort Service Avail...
 
Lucknow 💋 Escorts Service Lucknow Phone No 8923113531 Elite Escort Service Av...
Lucknow 💋 Escorts Service Lucknow Phone No 8923113531 Elite Escort Service Av...Lucknow 💋 Escorts Service Lucknow Phone No 8923113531 Elite Escort Service Av...
Lucknow 💋 Escorts Service Lucknow Phone No 8923113531 Elite Escort Service Av...
 
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...
 
Admirable # 00971529501107 # Call Girls at dubai by Dubai Call Girl
Admirable # 00971529501107 # Call Girls at dubai by Dubai Call GirlAdmirable # 00971529501107 # Call Girls at dubai by Dubai Call Girl
Admirable # 00971529501107 # Call Girls at dubai by Dubai Call Girl
 
Lucknow 💋 Call Girls in Lucknow ₹7.5k Pick Up & Drop With Cash Payment 892311...
Lucknow 💋 Call Girls in Lucknow ₹7.5k Pick Up & Drop With Cash Payment 892311...Lucknow 💋 Call Girls in Lucknow ₹7.5k Pick Up & Drop With Cash Payment 892311...
Lucknow 💋 Call Girls in Lucknow ₹7.5k Pick Up & Drop With Cash Payment 892311...
 
Lucknow 💋 Call Girl in Lucknow 10k @ I'm VIP Independent Escorts Girls 892311...
Lucknow 💋 Call Girl in Lucknow 10k @ I'm VIP Independent Escorts Girls 892311...Lucknow 💋 Call Girl in Lucknow 10k @ I'm VIP Independent Escorts Girls 892311...
Lucknow 💋 Call Girl in Lucknow 10k @ I'm VIP Independent Escorts Girls 892311...
 
Jeremy Casson - Top Tips for Pottery Wheel Throwing
Jeremy Casson - Top Tips for Pottery Wheel ThrowingJeremy Casson - Top Tips for Pottery Wheel Throwing
Jeremy Casson - Top Tips for Pottery Wheel Throwing
 
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...
Lucknow 💋 Call Girls in Lucknow | Service-oriented sexy call girls 8923113531...
 
RAK Call Girls Service # 971559085003 # Call Girl Service In RAK
RAK Call Girls Service # 971559085003 # Call Girl Service In RAKRAK Call Girls Service # 971559085003 # Call Girl Service In RAK
RAK Call Girls Service # 971559085003 # Call Girl Service In RAK
 
RAJKOT CALL GIRL 76313*77252 CALL GIRL IN RAJKOT
RAJKOT CALL GIRL 76313*77252 CALL GIRL IN RAJKOTRAJKOT CALL GIRL 76313*77252 CALL GIRL IN RAJKOT
RAJKOT CALL GIRL 76313*77252 CALL GIRL IN RAJKOT
 
Lucknow 💋 Russian Call Girls Lucknow | Whatsapp No 8923113531 VIP Escorts Ser...
Lucknow 💋 Russian Call Girls Lucknow | Whatsapp No 8923113531 VIP Escorts Ser...Lucknow 💋 Russian Call Girls Lucknow | Whatsapp No 8923113531 VIP Escorts Ser...
Lucknow 💋 Russian Call Girls Lucknow | Whatsapp No 8923113531 VIP Escorts Ser...
 
Call girls in Kanpur - 9761072362 with room service
Call girls in Kanpur - 9761072362 with room serviceCall girls in Kanpur - 9761072362 with room service
Call girls in Kanpur - 9761072362 with room service
 
Jeremy Casson - How Painstaking Restoration Has Revealed the Beauty of an Imp...
Jeremy Casson - How Painstaking Restoration Has Revealed the Beauty of an Imp...Jeremy Casson - How Painstaking Restoration Has Revealed the Beauty of an Imp...
Jeremy Casson - How Painstaking Restoration Has Revealed the Beauty of an Imp...
 
Dubai Call Girl Number # 00971588312479 # Call Girl Number In Dubai # (UAE)
Dubai Call Girl Number # 00971588312479 # Call Girl Number In Dubai # (UAE)Dubai Call Girl Number # 00971588312479 # Call Girl Number In Dubai # (UAE)
Dubai Call Girl Number # 00971588312479 # Call Girl Number In Dubai # (UAE)
 
Lucknow 💋 Escort Service in Lucknow (Adult Only) 8923113531 Escort Service 2...
Lucknow 💋 Escort Service in Lucknow  (Adult Only) 8923113531 Escort Service 2...Lucknow 💋 Escort Service in Lucknow  (Adult Only) 8923113531 Escort Service 2...
Lucknow 💋 Escort Service in Lucknow (Adult Only) 8923113531 Escort Service 2...
 
(NEHA) Call Girls Mumbai Call Now 8250077686 Mumbai Escorts 24x7
(NEHA) Call Girls Mumbai Call Now 8250077686 Mumbai Escorts 24x7(NEHA) Call Girls Mumbai Call Now 8250077686 Mumbai Escorts 24x7
(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
  • 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<"-" ;