The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 06-28-2009
kshji's Avatar
kshji kshji is offline
Registered User
  
 

Join Date: Jun 2009
Location: Finland
Posts: 236
You can do this many way, but here is one example how to use parameter expansion.

Code:
#!/bin/ksh
# read lines from stdin
while read line
do
        # remove begin of line including <html>
        a1=${line#*<html>}
        # remove end of line including </html>
        a2=${a1%</html>*}
        # remove all char except numbers (replace not numbers with nothing)
        a3=${a2//[^0-9]/}
        print $a3
done

And then run it

Code:
chmod a+x thisfile
cat file1 | ./thisfile > file2