concept Bash in category security

This is an excerpt from Manning's book The Art of Network Penetration Testing.
Even if you use the ping flag -W 1 to force the timeout to be only 1 second on non-live hosts, it would still take an unnecessarily long time to successfully sweep an entire network range. This is where the power of scripting with Bash comes in handy. The following is a little trick you can try on your LAN to use 1 line of Bash that sends 255 pings in just a couple of seconds. First, I’ll show you the command and then I’ll break down all the different pieces.
~$ for octet in {1..255}; do ping -c 1 10.0.10.$octet -W 1 >> pingsweep.txt & doneFor this command to work on your network, you’ll have to replace 10.0.10 with the first three octets of your LAN. It creates a Bash for loop that is executed 255 times. Each time it executes, the variable $octet has an incrementing numeric value. First it will be 1, then 2, and then 3; you get the idea.
The first iteration will look like this ping -c 1 10.0.10.1 -W 1 >> pingsweep.txt &. The & in this command tells Bash to background the job, which means you don’t have to wait for it to complete before issuing the next command. The >> tells Bash to append the output of each command to a file named pingsweep.txt. Once the loop is done you can cat the file with cat pingsweep.txt to see the output of all 255 commands. Because you’re really interested in identifying only live hosts, you can use the grep command to display the information you want. Use the command cat pingsweep.txt | grep "bytes from:" to limit the results of your cat command to only show lines that contain the string "bytes from". This essentially means the IP address send a reply. You can see the output in listing 2.2 shows a total of 22 live hosts returned from the pingsweep.
If you aren’t an avid command line user, then at first the msfconsole might seem a little bit foreign. Don’t be intimidated: the easiest way to understand it is to think of the console as a sort of command prompt within a command prompt, except this command prompt speaks Metasploit instead of Bash.