SlideShare a Scribd company logo
crontab and more
crontab and more
By : Khawar Nehal
26 October 2021
Agenda
awk
crontab
At
Shell scripting ( sh , bash )
Quizzes
Bloomy Week 3
Linux: Quiz 1
https://bloomy360.moodlecloud.com/mod/quiz/view.php?i
d=68
Linux: Quiz 2
https://bloomy360.moodlecloud.com/mod/quiz/view.php?i
d=69
Bloomy Week 5
Linux: Quiz
https://bloomy360.moodlecloud.com/mod/quiz/view.php?i
d=95
Awk
$cat > employee.txt
ajay manager account 45000
sunil clerk account 25000
varun manager sales 50000
amit manager account 47000
tarun peon sales 15000
deepak clerk sales 23000
sunil peon sales 13000
satvik director purchase 80000
Awk
$ awk '{print}' employee.txt
Output:
ajay manager account 45000
sunil clerk account 25000
varun manager sales 50000
amit manager account 47000
tarun peon sales 15000
deepak clerk sales 23000
sunil peon sales 13000
satvik director purchase 80000
Awk
Print the lines which match the given pattern.
$ awk '/manager/ {print}' employee.txt
Output:
ajay manager account 45000
varun manager sales 50000
amit manager account 47000
Awk
Splitting a Line Into Fields : For each record i.e line, the awk
command splits the record delimited by whitespace character by
default and stores it in the $n variables. If the line has 4 words, it
will be stored in $1, $2, $3 and $4 respectively. Also, $0 represents
the whole line.
Awk
$ awk '{print $1,$4}' employee.txt
Output:
ajay 45000
sunil 25000
varun 50000
amit 47000
tarun 15000
deepak 23000
sunil 13000
satvik 80000
Awk
In the above example, $1 and $4 represents Name and Salary
fields respectively.
Built-In Variables In Awk
Awk’s built-in variables include the field variables—$1, $2, $3, and
so on ($0 is the entire line) — that break a line of text into
individual words or pieces called fields.
Awk
NR: NR command keeps a current count of the number of input
records. Remember that records are usually lines. Awk command
performs the pattern/action statements once for each record in a
file.
NF: NF command keeps a count of the number of fields within
the current input record.
FS: FS command contains the field separator character which is
used to divide fields on the input line. The default is “white space”,
meaning space and tab characters. FS can be reassigned to
another character (typically in BEGIN) to change the field
separator.
Awk
RS: RS command stores the current record separator character.
Since, by default, an input line is the input record, the default
record separator character is a newline.
OFS: OFS command stores the output field separator, which
separates the fields when Awk prints them. The default is a blank
space. Whenever print has several parameters separated with
commas, it will print the value of OFS in between each parameter.
ORS: ORS command stores the output record separator, which
separates the output lines when Awk prints them. The default is a
newline character. print automatically outputs the contents of ORS
at the end of whatever it is given to print.
Awk
Examples:
Use of NR built-in variables (Display Line Number)
$ awk '{print NR,$0}' employee.txt
Output:
1 ajay manager account 45000
2 sunil clerk account 25000
3 varun manager sales 50000
4 amit manager account 47000
5 tarun peon sales 15000
6 deepak clerk sales 23000
7 sunil peon sales 13000
8 satvik director purchase 80000
Awk
In the above example, the awk command with NR prints all the lines along with
the line number.
Use of NF built-in variables (Display Last Field)
Awk
$ awk '{print $1,$NF}' employee.txt
Output:
ajay 45000
sunil 25000
varun 50000
amit 47000
tarun 15000
deepak 23000
sunil 13000
satvik 80000
In the above example $1 represents Name and $NF represents Salary. We can
get the Salary using $NF , where $NF represents last field.
Awk
Another use of NR built-in variables (Display Line From 3 to 6)
$ awk 'NR==3, NR==6 {print NR,$0}' employee.txt
Output:
3 varun manager sales 50000
4 amit manager account 47000
5 tarun peon sales 15000
6 deepak clerk sales 23000
Awk
$cat > geeksforgeeks.txt
A B C
Tarun A12 1
Man B6 2
Praveen M42 3
Awk
1) To print the first item along with the row number(NR) separated with ” – “ from
each line in geeksforgeeks.txt:
$ awk '{print NR "- " $1 }' geeksforgeeks.txt
1 - A
2 - Tarun
3 – Manav
4 - Praveen
Awk
To return the second row/item from geeksforgeeks.txt:
The question should be:- To return the second column/item from
geeksforgeeks.txt:
$ awk '{print $2}' geeksforgeeks.txt
A12
B6
M42
Awk
More on awk
https://www.geeksforgeeks.org/awk-command-unixlinux-examples/
Cron
Cron
Cron
Cron
Cron
Cron
Cron
Cron
Cron
Cron
Cron
Cron
Cron
Cron
Cron
More on crontab
https://www.adminschoice.com/crontab-quick-refe
rence
crontab
Crontab calculator
https://crontab.guru/

More Related Content

PDF
Docopt
PPTX
Formatted Console I/O Operations in C++
ODP
Functional perl
PDF
Greyhound - Powerful Pure Functional Kafka Library - Scala Love in the City
PDF
Phil Bartie QGIS PLPython
PDF
Faster Python, FOSDEM
PPTX
Return Oriented Programming (ROP chaining)
PDF
Workshop on command line tools - day 2
Docopt
Formatted Console I/O Operations in C++
Functional perl
Greyhound - Powerful Pure Functional Kafka Library - Scala Love in the City
Phil Bartie QGIS PLPython
Faster Python, FOSDEM
Return Oriented Programming (ROP chaining)
Workshop on command line tools - day 2

What's hot (20)

PDF
Workshop on command line tools - day 1
PDF
ES6 Simplified
PDF
Dataflow: Declarative concurrency in Ruby
PDF
Dig1108 Lesson 3
PDF
The Art of Command Line (2021)
PPTX
Intro to C++
PPTX
Command line arguments
DOCX
Exercice.docx
PPTX
JavaScript Event Loop
PDF
Advanced Patterns with io.ReadWriter
PPTX
Variadic functions
PDF
Hive practice
PPT
01c shell
PDF
Performance testing of microservices in Action
ODP
Exploiting Memory Overflows
PPTX
Introduction to Ecmascript - ES6
PDF
TLPI - 6 Process
PDF
ES2015 (ES6) Overview
PDF
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
Workshop on command line tools - day 1
ES6 Simplified
Dataflow: Declarative concurrency in Ruby
Dig1108 Lesson 3
The Art of Command Line (2021)
Intro to C++
Command line arguments
Exercice.docx
JavaScript Event Loop
Advanced Patterns with io.ReadWriter
Variadic functions
Hive practice
01c shell
Performance testing of microservices in Action
Exploiting Memory Overflows
Introduction to Ecmascript - ES6
TLPI - 6 Process
ES2015 (ES6) Overview
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
Ad

Similar to Linux class 15 26 oct 2021 (20)

DOCX
Awk programming
PPS
Unix - Class7 - awk
PPT
awk_intro.ppt
PPTX
Shell scripting
PDF
Awk A Pattern Scanning And Processing Language
PPT
Unix day4 v1.3
PDF
Advanced perl finer points ,pack&unpack,eval,files
TXT
Lab07 (1)
PDF
Awk Introduction
PDF
NS2: AWK and GNUplot - PArt III
PDF
lab-assgn-practical-file-xii-cs.pdf
PDF
Awk-An Advanced Filter
PPTX
VI Editor
PPSX
Awk essentials
DOCX
of 70UNIX Unbounded 5th EditionAmir Afzal .docx
DOCX
of 70UNIX Unbounded 5th EditionAmir Afzal .docx
PPTX
RHCSA EX200 - Summary
PPTX
Macros for Shape and formula
PPT
ShellAdvanced shell scripting programm.ppt
PPT
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
Awk programming
Unix - Class7 - awk
awk_intro.ppt
Shell scripting
Awk A Pattern Scanning And Processing Language
Unix day4 v1.3
Advanced perl finer points ,pack&unpack,eval,files
Lab07 (1)
Awk Introduction
NS2: AWK and GNUplot - PArt III
lab-assgn-practical-file-xii-cs.pdf
Awk-An Advanced Filter
VI Editor
Awk essentials
of 70UNIX Unbounded 5th EditionAmir Afzal .docx
of 70UNIX Unbounded 5th EditionAmir Afzal .docx
RHCSA EX200 - Summary
Macros for Shape and formula
ShellAdvanced shell scripting programm.ppt
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
Ad

More from Khawar Nehal khawar.nehal@atrc.net.pk (20)

PDF
Linux Class 1 Reasons to use linux
PDF
Same old lessons in investing
PDF
Linux class 10 15 oct 2021-6
PDF
Linux class 9 15 oct 2021-5
PDF
File systems linux class 8
PDF
Linux commands Class 5 - 8 oct 2021
PDF
Linux course fhs file hierarchy standard
PDF
Linux passwords class 4
PDF
Using linux 5 oct 2021 3
PDF
Everyday uses of linux
PDF
Artificial Intelligence by Khawar Nehal
PDF
Artificial Intelligence in Banking
PDF
RevOps Revenue Operations
PDF
Management techniques of the world by khawar nehal 4 august 2020-1
PDF
Kona (TM) Autonomous Cars Anti Collision System
PDF
What was learned about what works in distance learning in 2020
Linux Class 1 Reasons to use linux
Same old lessons in investing
Linux class 10 15 oct 2021-6
Linux class 9 15 oct 2021-5
File systems linux class 8
Linux commands Class 5 - 8 oct 2021
Linux course fhs file hierarchy standard
Linux passwords class 4
Using linux 5 oct 2021 3
Everyday uses of linux
Artificial Intelligence by Khawar Nehal
Artificial Intelligence in Banking
RevOps Revenue Operations
Management techniques of the world by khawar nehal 4 august 2020-1
Kona (TM) Autonomous Cars Anti Collision System
What was learned about what works in distance learning in 2020

Recently uploaded (20)

PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Basic Mud Logging Guide for educational purpose
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
01-Introduction-to-Information-Management.pdf
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Sports Quiz easy sports quiz sports quiz
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
RMMM.pdf make it easy to upload and study
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Institutional Correction lecture only . . .
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
TR - Agricultural Crops Production NC III.pdf
Pharma ospi slides which help in ospi learning
FourierSeries-QuestionsWithAnswers(Part-A).pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
Microbial diseases, their pathogenesis and prophylaxis
2.FourierTransform-ShortQuestionswithAnswers.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Basic Mud Logging Guide for educational purpose
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
01-Introduction-to-Information-Management.pdf
Insiders guide to clinical Medicine.pdf
Final Presentation General Medicine 03-08-2024.pptx
Sports Quiz easy sports quiz sports quiz
VCE English Exam - Section C Student Revision Booklet
RMMM.pdf make it easy to upload and study
O7-L3 Supply Chain Operations - ICLT Program
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Institutional Correction lecture only . . .

Linux class 15 26 oct 2021

  • 2. crontab and more By : Khawar Nehal 26 October 2021
  • 4. Quizzes Bloomy Week 3 Linux: Quiz 1 https://bloomy360.moodlecloud.com/mod/quiz/view.php?i d=68 Linux: Quiz 2 https://bloomy360.moodlecloud.com/mod/quiz/view.php?i d=69 Bloomy Week 5 Linux: Quiz https://bloomy360.moodlecloud.com/mod/quiz/view.php?i d=95
  • 5. Awk $cat > employee.txt ajay manager account 45000 sunil clerk account 25000 varun manager sales 50000 amit manager account 47000 tarun peon sales 15000 deepak clerk sales 23000 sunil peon sales 13000 satvik director purchase 80000
  • 6. Awk $ awk '{print}' employee.txt Output: ajay manager account 45000 sunil clerk account 25000 varun manager sales 50000 amit manager account 47000 tarun peon sales 15000 deepak clerk sales 23000 sunil peon sales 13000 satvik director purchase 80000
  • 7. Awk Print the lines which match the given pattern. $ awk '/manager/ {print}' employee.txt Output: ajay manager account 45000 varun manager sales 50000 amit manager account 47000
  • 8. Awk Splitting a Line Into Fields : For each record i.e line, the awk command splits the record delimited by whitespace character by default and stores it in the $n variables. If the line has 4 words, it will be stored in $1, $2, $3 and $4 respectively. Also, $0 represents the whole line.
  • 9. Awk $ awk '{print $1,$4}' employee.txt Output: ajay 45000 sunil 25000 varun 50000 amit 47000 tarun 15000 deepak 23000 sunil 13000 satvik 80000
  • 10. Awk In the above example, $1 and $4 represents Name and Salary fields respectively. Built-In Variables In Awk Awk’s built-in variables include the field variables—$1, $2, $3, and so on ($0 is the entire line) — that break a line of text into individual words or pieces called fields.
  • 11. Awk NR: NR command keeps a current count of the number of input records. Remember that records are usually lines. Awk command performs the pattern/action statements once for each record in a file. NF: NF command keeps a count of the number of fields within the current input record. FS: FS command contains the field separator character which is used to divide fields on the input line. The default is “white space”, meaning space and tab characters. FS can be reassigned to another character (typically in BEGIN) to change the field separator.
  • 12. Awk RS: RS command stores the current record separator character. Since, by default, an input line is the input record, the default record separator character is a newline. OFS: OFS command stores the output field separator, which separates the fields when Awk prints them. The default is a blank space. Whenever print has several parameters separated with commas, it will print the value of OFS in between each parameter. ORS: ORS command stores the output record separator, which separates the output lines when Awk prints them. The default is a newline character. print automatically outputs the contents of ORS at the end of whatever it is given to print.
  • 13. Awk Examples: Use of NR built-in variables (Display Line Number) $ awk '{print NR,$0}' employee.txt Output: 1 ajay manager account 45000 2 sunil clerk account 25000 3 varun manager sales 50000 4 amit manager account 47000 5 tarun peon sales 15000 6 deepak clerk sales 23000 7 sunil peon sales 13000 8 satvik director purchase 80000
  • 14. Awk In the above example, the awk command with NR prints all the lines along with the line number. Use of NF built-in variables (Display Last Field)
  • 15. Awk $ awk '{print $1,$NF}' employee.txt Output: ajay 45000 sunil 25000 varun 50000 amit 47000 tarun 15000 deepak 23000 sunil 13000 satvik 80000 In the above example $1 represents Name and $NF represents Salary. We can get the Salary using $NF , where $NF represents last field.
  • 16. Awk Another use of NR built-in variables (Display Line From 3 to 6) $ awk 'NR==3, NR==6 {print NR,$0}' employee.txt Output: 3 varun manager sales 50000 4 amit manager account 47000 5 tarun peon sales 15000 6 deepak clerk sales 23000
  • 17. Awk $cat > geeksforgeeks.txt A B C Tarun A12 1 Man B6 2 Praveen M42 3
  • 18. Awk 1) To print the first item along with the row number(NR) separated with ” – “ from each line in geeksforgeeks.txt: $ awk '{print NR "- " $1 }' geeksforgeeks.txt 1 - A 2 - Tarun 3 – Manav 4 - Praveen
  • 19. Awk To return the second row/item from geeksforgeeks.txt: The question should be:- To return the second column/item from geeksforgeeks.txt: $ awk '{print $2}' geeksforgeeks.txt A12 B6 M42
  • 21. Cron
  • 22. Cron
  • 23. Cron
  • 24. Cron
  • 25. Cron
  • 26. Cron
  • 27. Cron
  • 28. Cron
  • 29. Cron
  • 30. Cron
  • 31. Cron
  • 32. Cron
  • 33. Cron
  • 34. Cron