The UNIX and Linux Forums  

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



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
redirect cat to variable shailesh_arya Shell Programming and Scripting 7 07-10-2008 05:34 AM
after grep i want to redirect it to some variable mail2sant Shell Programming and Scripting 2 04-07-2008 10:26 AM
Redirect to variable MrAd UNIX for Dummies Questions & Answers 2 05-07-2007 05:18 PM
Redirect Output In Variable ZINGARO UNIX for Dummies Questions & Answers 1 08-02-2006 07:56 AM
please help: how to redirect input into a variable artur80 Shell Programming and Scripting 2 11-17-2002 10:18 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #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}'
  #2 (permalink)  
Old 11-22-2008
oxoxo oxoxo is offline
Banned
  
 

Join Date: Sep 2008
Posts: 38
Code:
cat Hello.txt | egrep "That One Pattern" | awk '{print $NF}'
I have a value in that code. But i cant add it to anything. Awk has its own language so i cant change the NF variable to preform any arithmetic with other command lines...Not that i could of anyway. right?

So i used another method:
Code:
cat Hello.txt | egrep "That One Pattern" | cut -d':' -f2
That code has a value as well. How would i store it in a varaible??

Code:
Value=Hello.txt | egrep "That one Pattern" | cut -d':' -f2
har har har. But i really dont know.


-----------------------------------------------
Everybody looks cool at blacklight parties
execpt for me, because i was under the impretion
that the mustard stain came out...
------------------------------------------------
  #3 (permalink)  
Old 11-22-2008
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,576
Dont undestand what you want...
Is it assign to a variable the result of one of your commands above?
in ksh you would do so like that:
Code:
VAL1=$(cat Hello.txt | egrep "That One Pattern" | awk '{print $NF}')
#to check
echo " VAL1 = " $VAL1
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0