How to run a command on a filtered file list returned by grep

I often find myself passing a file list returned by some linux command to grep for filtering like below :
ls *.jar | grep test 

Sometimes i like to run a certain command on these filtered results. I achieve this by :

ls *.jar | grep test | while read line; do sha1sum "$line"; done

The generic form is :
<command generating a file list>   |   grep <filter keyword> | while read line; do <command> "$line"; done  

How to check if a port is open on Linux

Sometimes when writing a script/program you need to know if a port your are interested in has an established connection to it or it's free.

My favorite way to do this is to run the following command ( replace PORT with the port number you want to check for ):

netstat -ln | grep :PORT
-l = Show only listening ports
-n = Show port number
 If this command doesn't return anything, it shows that your PORT is available to use.
In your script you can check $? to see the return code of the above command. If it's non-zero, the PORT is available.

One thing to note though is that, this doesn't tell you the status of your network e.g. if PORT is accessible from outside of your notwork.