The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
storing result of a command in variable eltinator Shell Programming and Scripting 1 04-17-2008 09:09 PM
How to get a result of a cmd into variable? manchau UNIX and Linux Applications 1 03-06-2008 07:36 AM
Problem storing SSH result in a variable prash184u Shell Programming and Scripting 1 01-17-2008 04:41 PM
populate variable from remote result hcclnoodles Shell Programming and Scripting 2 02-19-2007 05:44 AM
Setting a variable to result of FIND command JP Favara Windows & DOS: Issues & Discussions 2 03-09-2005 10:17 PM

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-13-2006
kykyboss kykyboss is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 10
cree a variable from a commande result

Hi everybody

I m looking the put the result of a commande to a Variable
i explain


here is my command:

cat sortie | grep "^[1-9999]"| awk '{ print $1}'
15


sortie is a text file
I want to put the result of command in a variable X

and the end i would like

echo $X
15

I hope you understand what i want to do, sorry for my english
I m french

Last edited by kykyboss; 11-13-2006 at 10:38 AM..
  #2 (permalink)  
Old 11-13-2006
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,433
With KSH and BASH:

Code:
X=$(awk '/^[1-9999]/ {print $1}' sortie)

With SH, KSH and BASH:

Code:
X=`awk '/^[1-9999]/ {print $1}' sortie`


Jean-Pierre.
  #3 (permalink)  
Old 11-13-2006
kykyboss kykyboss is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 10
thank i found it


x=`cat sortie | grep "^[1-9999]"| awk '{ print $1}'`


i m a beginner
  #4 (permalink)  
Old 11-13-2006
kykyboss kykyboss is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 10
thank aigle that work problem close
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 05:56 AM.


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