The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 11-22-2008
oxoxo oxoxo is offline
Banned
  
 

Join Date: Sep 2008
Posts: 38
Redirect to a Variable? Or is it cmd cap?

Hi,

Im reading an ANSI text file and greping for a pattern. Then i cut what i dont need from that pattern. So now i just have what i need. What i have now just so happens to be a constant integer. How can i save this integer in a varaible? Or do i use command capture in some form?


Code:
cat Hello.txt | egrep "That One Pattern" | awk '{print $NF}'

Also..This command might be really useful to me, i just dont understand it.
Since maybe i can use these varaibles with the one i would like to store above..


Code:
awk '{for (i=1; i<=NF; i++) s=s+$i}; END{print s}'