Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-05-2010, 02:10 PM   #1
LQ Newbie
Registered: Oct 2010
Posts: 1

Rep: Reputation: 0
Assigning variable is messing up

I am trying to run this and was into issues

function() {
node=echo "" | awk '{split ($0, a, "."); print a[1]}'

function1() {
echo $a
echo $a "- 2nd time"

This output's first a as 10, that's ok but second a as "0", so i was unable to use it anywhere inscript for second time.

I found the actual issue, but I wanna know why is it so

node=`echo "" | awk '{split ($0, a, "."); print a[1]}'`
The above line works, but why?

Can someone please help me

Thank you

Last edited by voldemort; 11-05-2010 at 02:11 PM. Reason: missed some lines
Old 11-05-2010, 02:26 PM   #2
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Oh He-Who-Must-Not-Be-Named: it's called "Command Substitution".

You can use a=`echo "ABC"`.

You can also use the equivalent a=$(echo "ABC").

'Hope that helps!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Assigning (tail) results to a variable WhisperiN Programming 4 10-17-2009 08:33 AM
Trouble assigning value to variable with fatsheep Programming 1 11-07-2006 07:44 PM
getting rpoblem in assigning value to variable in if construct Ankit mittal Programming 9 01-07-2006 09:12 AM
assigning commands to a variable aunquarra Linux - General 5 01-04-2006 07:58 AM
in C, Assigning output of system() to a variable Miaire Programming 4 01-30-2005 12:40 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:42 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration