www.theunixschool.com Open in urlscan Pro
2a00:1450:4001:82f::2013  Public Scan

Submitted URL: http://unix-school.blogspot.com/
Effective URL: https://www.theunixschool.com/
Submission: On May 27 via api from GB — Scanned from GB

Form analysis 2 forms found in the DOM

POST http://feedburner.google.com/fb/a/mailverify

<form style="border:1px solid #ccc;padding:3px;text-align:left;" action="http://feedburner.google.com/fb/a/mailverify" method="post" target="popupwindow"
  onsubmit="window.open('http://feedburner.google.com/fb/a/mailverify?uri=http/unix-schoolblogspotcom', 'popupwindow', 'scrollbars=yes,width=550,height=550');return true">
  <font size="2">Enter your email address to receive new articles by email as we post it!!!</font><br><input type="text" style="width:200px" name="email" placeholder="Email address..."><input type="hidden" value="http/unix-schoolblogspotcom"
    name="uri"><input type="hidden" name="loc" value="en_US"><input type="submit" value="Submit">
</form>

https://www.theunixschool.com/search

<form action="https://www.theunixschool.com/search" class="gsc-search-box" target="_top">
  <table cellpadding="0" cellspacing="0" class="gsc-search-box">
    <tbody>
      <tr>
        <td class="gsc-input">
          <input autocomplete="off" class="gsc-input" name="q" size="10" title="search" type="text" value="">
        </td>
        <td class="gsc-search-button">
          <input class="gsc-search-button" title="search" type="submit" value="Search">
        </td>
      </tr>
    </tbody>
  </table>
</form>

Text Content

PAGES

 * Home
 * Shell Scripts
 * Different methods
 * awk & sed
 * Online Training
 * About






TUESDAY, MAY 19, 2020


LINUX SHELL - WHAT IS IFS?


 IFS stands for internal field separator. This is the delimiter used when words
are split.

The man page of bash tells :

IFS    The Internal Field Separator that is used for word splitting after
expansion and to split lines into
              words with the read builtin command.  The default value is
``<space><tab><newline>''.



The default value of IFS is a space, a tab followed by a newline.

guru@unixschool:~$ echo "$IFS"
  

guru@unixschool:~$ echo "$IFS" | cat -tve
 ^I$
$
guru@unixschool:~$ 


  When we echoed IFS for the first time, we could not see anything becuase they
are special characters. On using the tve options of cat, we can see a space,
followed by a ^I which is a tab character and then followed by a newline.


(Read the complete article.....)
No comments:




THURSDAY, MAY 14, 2020


PYTHON - HOW DOES AN ITERATOR WORK


 In this article, we will discuss how does an iterator work.  Python has 2
function related to iterator: iter and next. iter creates an iteration object
for the requested input, and the next function returns the next element present
in the iterator. next keeps on returning till the last element is reached.

   Let us create an iterator for a list and see how the next and iter function
works:


>>> l1 = [2,25,33,12]
>>> l1
[2, 25, 33, 12]
>>> it1 = iter(l1)
>>> it1
<list_iterator object at 0x7fc24f93aa58>
>>> next(it1)
2
>>> next(it1)
25
>>> next(it1)
33
>>> next(it1)
12
>>> next(it1)
Traceback (most recent call last):
  File "", line 1, in 
StopIteration
>>> 


When we printed it1, it shows it as an list_iterator object. Everytime next is
hit, it gave the next element and finally when there are no more elements, it
gives StopIteration.


(Read the complete article.....)
No comments:




TUESDAY, MAY 5, 2020


BASH - 5 EXAMPLES TO DO ARITHMETIC OPERATIONS


 While working in bash or while writing bash scripts, many times it so happens
we rely on external commands to get our math done. Most of the arithmetic can be
handled by the bash itself.   In this article, we will see how to do arithmetic
operations in bash.

1. Add / Subtract numbers:
     One common way to basic arithmetic using bash is by using the let command.


x=20
y=30
let z=x+y
echo "z is $z"


  This is purely a shell operation without any external command. This way one
can do for subtract(/), multiply(*), divide(/) and remainder(%) operation.


x=20
y=30
((z=x+y))
echo "z is $z"


  The other way to do is using the ((expression)) where the expression is an
arithmetic one. Using this double brace notation, all the bash arithmetic can be
done.
   Bash also allows to use +=, -= operators like in many programming languages.
So, if we have something like x=x+10, it can be written as


x=40
((x+=10))
echo "x is $x"



(Read the complete article.....)
No comments:




THURSDAY, APRIL 30, 2020


PYTHON - HOW TO READ A FILE?


   In this article, we will see how to read from a file. Let us have file with
content as below:


$ cat file
Unix
Linux
AIX


1.  Reading line by line:


>>> fd = open('/home/guru/file', 'r')
>>> for line in fd:
...   print(line)
... 
Unix

Linux

AIX

>>> 


         open function opens a file and returns a file object.  Arguments are
filename and the mode, 'r' for reading.  When the file object is traversed,
every iteration reads a line and line gets printed. Notice the blank line after
every print. This is because the variable line contains a newline character read
from the file and print function adds another newline.



(Read the complete article.....)
No comments:




TUESDAY, APRIL 28, 2020


BASH - 10 EXAMPLES TO FIND / REPLACE IN A STRING


Many times when we want to replace or extract something, we immediately end up
with and awk or a sed oneliner. Keep in mind, the first option should always be
a internal shell option, only in the absence of which we should resort to an
external command. In this article, we will see 10 different examples where
instead of an awk/sed, using bash specific internal will be very beneficial:

1. Capitalize a string:  Though there are many ways to capitalize a string,  one
tends to use toupper function to get it done. Instead, bash can directly handle
it.


$ x='hello'
$ echo ${x^^}
HELLO
$ echo "$x" | awk '{print toupper($0)}'
HELLO


   This feature of bash(^^) is only available for bash version 4. The two carrot
pattern capitalizes the entire string.


(Read the complete article.....)
No comments:


Older Posts Home

Subscribe to: Posts (Atom)



GET FREE UPDATES

Enter your email address to receive new articles by email as we post it!!!






JOIN US





GREP THE UNIX SCHOOL






FACEBOOK FANS





POPULAR POSTS OF THE UNIX SCHOOL

 * Linux Interview Questions - Part 1
 * 10 tips to improve performance of shell script
 * sed - 25 examples to delete a line in a file
 * Shell Script to do shell scripting faster
 * 10 examples to group data in a CSV file
 * What is SUID
 * 5 important things to follow to be a fast learner




BLOG ARCHIVE

 * ▼  2020 (7)
   * ▼  May (3)
     * Linux Shell - What is IFS?
     * Python - How does an iterator work
     * bash - 5 examples to do arithmetic operations
   * ►  April (4)

 * ►  2017 (3)
   * ►  July (1)
   * ►  January (2)

 * ►  2014 (2)
   * ►  September (1)
   * ►  August (1)

 * ►  2013 (19)
   * ►  November (1)
   * ►  August (1)
   * ►  July (3)
   * ►  May (1)
   * ►  April (1)
   * ►  March (2)
   * ►  February (5)
   * ►  January (5)

 * ►  2012 (81)
   * ►  December (6)
   * ►  November (6)
   * ►  October (5)
   * ►  September (8)
   * ►  August (8)
   * ►  July (5)
   * ►  June (9)
   * ►  May (9)
   * ►  April (11)
   * ►  March (10)
   * ►  February (3)
   * ►  January (1)

 * ►  2011 (29)
   * ►  September (4)
   * ►  August (3)
   * ►  July (3)
   * ►  June (4)
   * ►  May (3)
   * ►  April (1)
   * ►  March (6)
   * ►  February (3)
   * ►  January (2)

 * ►  2010 (36)
   * ►  December (2)
   * ►  November (1)
   * ►  October (2)
   * ►  September (2)
   * ►  August (2)
   * ►  July (3)
   * ►  June (5)
   * ►  May (4)
   * ►  April (5)
   * ►  March (3)
   * ►  February (1)
   * ►  January (6)








Copyright © 2013 The UNIX School. All rights reserved. Powered by Blogger.



This site uses cookies from Google to deliver its services and to analyse
traffic. Your IP address and user agent are shared with Google, together with
performance and security metrics, to ensure quality of service, generate usage
statistics and to detect and address abuse.Learn moreOk
ShareThis Copy and Paste