More videos like this online at www.theurbanpenguin.com
Now we really have some fun with our scripts adding in TRAP to help make the scripts more robust. We may need our script to exit correctly each time. We can do this by creating a PID file and checking for its existence. If it does exist then the script did not exit cleanly last time. we also then must make sure we provide a method to delete the file as we exit. Scripts normally do not respond to terminate signals sent from kill, but we too can eable this with traps to make sure we listen to calls from the system, I am sure this will help with your scripts and you will want to implement these ideas in some of your projects.
Have you mastered the basics? Handy with a one-liner? Looking to extend your scripting prowess? Come learn to take simple commands and add logic to them to produce speed and efficiency. Manipulate strings to harvest just the nugget of information youre after without extraneous formatting and labels. Learn why I sed awk.
We know you w`ant to speed up your shell usage and in this vide we show you how to create a simple bash one-liner to create a complete subdirectory tree. Using BASH we can use simple syntax to create one-liner commands lines that are powerful
md ca/{root-ca,sub-ca}/{private,db,certs}
Extend this too, by setting the mode of both private directories
Make sure to subscribe to my channel for more videos on UNIX, Perl and SQL.
facebook: facebook.com/fuzicast
twitter: @fuzicast
youtube: youtube.com/yuejdesigner85
awk -F| BEGIN{ initialization } { code block } END{ finalization } — general syntax
default delimiter is space
VAR=«value» — define a variable
print VAR — print a variable
NF is number of fields
$NF is value of last field
print "$EXTERNAL_VAR" — double single $EXTERNAL_VAR single double
VAR~/pattern/ — pattern patching
VAR!~/pattern/ — does not match
FS returns value of field separator, same as -F
OFS returns output field separator
print $1,$2 is separated
NR returns line number
FILENAME returns current filename
awk -v var1=value1 — pre-assign values to variables in awk
awk -F, conditions { code block } filename — condition must be right before code block
cut — get columns from file
cut -d, -f1-2 filename — print 1st to 2nd columns
cut -c1-5 filename — print first 5 characters
cut -d, -f2- filename — print from 2nd column to last column
cut -d, -f1,4,5 filename — print 1st, 4th and 5th column
cut -d, -f-3 filename — print from 1st to 3rd column
cut -d, -f1,3-5 filename — print 1st, 3rd to 5th column
wc — word count
wc -l — line count
wc -c — print number of bytes
wc — print number of newline, word and bytes
wc -m — character count
wc -w — word count
last — check login history
last -10 — show last 10 logins
last -F — show full login information
If you are serious about gaining your Linux Essentials certification you can gain a heavily discounted price to my Linux Essentials course via this link: www.udemy.com/learning-linux-essentials-taking-your-first-steps-in-linux/?couponCode=youtube-video
More videos like this online at www.theurbanpenguin.com
Topic 3.2 takes us into the realms of searching for files and data. We start with a little file redirection using the greater than symbols. then into piping using the vertical bar. Big area next looking at the tools such as find, cut, head, tail before we look at grep with regular expressions.
In this video we look at installing FreeBSD 12, the open UNIX operation system that widley available. FreeBSD is open source softeware that is released under a simple license In stalling this is simple but we exaplain each step and look at udating it after the installation. Later we can see how to upgrade to relase 12.1