LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-31-2015, 02:31 AM   #1
Upendra Pratap Singh
Member
 
Registered: May 2011
Location: India
Distribution: Ubuntu 14.04
Posts: 110
Blog Entries: 4

Rep: Reputation: 0
problem in interpreting command output


Hi,

I have executed a command

Code:
echo $(cat text)
where text is a file containing two columns. It is actually a symbol table.

I am not able to interpret the output of this command.

What is it actually doing?
 
Old 07-31-2015, 04:06 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,491

Rep: Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867
As you provided no output it is difficult to understand what your issue is? Why are you not able to "interpret the output"?
 
Old 08-02-2015, 12:37 AM   #3
Upendra Pratap Singh
Member
 
Registered: May 2011
Location: India
Distribution: Ubuntu 14.04
Posts: 110
Blog Entries: 4

Original Poster
Rep: Reputation: 0
The file text was having a mapping between two strings. The file thus contained two columns.

Example

Quote:
string1 string11
string2 string22
The output of $(cat text) was

Quote:
string1 string11 string2 string22
and so one. Basically it contained all the entries in a line without regard to newline between string11 and string2.

There was a program in which counter variable i was running from 1 up to $(cat text). So I wanted to know the value of $(cat text)

But then, when I echoed the value of $(cat text), I got the output as
Quote:
string1 string11 string2 string22
.

Last edited by Upendra Pratap Singh; 08-02-2015 at 12:38 AM.
 
Old 08-02-2015, 12:49 AM   #4
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 831

Rep: Reputation: 200Reputation: 200Reputation: 200
AFAIK echo adds a new line only at the end and spaces between strings.

So to really know the actual contents of the file called text (ie whether there is a new line between string11 and string2) , just say cat text at the command prompt.

OK
 
Old 08-02-2015, 01:04 AM   #5
Upendra Pratap Singh
Member
 
Registered: May 2011
Location: India
Distribution: Ubuntu 14.04
Posts: 110
Blog Entries: 4

Original Poster
Rep: Reputation: 0
If i is to run from 1 up to $(cat text), then $(cat text) must be a value.

Am I wrong if I say this?
 
Old 08-02-2015, 01:53 AM   #6
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 831

Rep: Reputation: 200Reputation: 200Reputation: 200
See this.
Code:
myname@myname-laptop:~$ cat text  
string1 string11                                <<== CORRECT RESULT
string2 string22
myname@myname-laptop:~$ echo $(cat text)
string1 string11 string2 string22               <<== WRONG RESULT
myname@padmanaban-laptop:~$
U is not to run anywhere.

If i is used as an index, then please OPEN (explain with reference to context) IN ANOTHER THREAD

OK
 
Old 08-02-2015, 03:47 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,491

Rep: Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867
Quote:
Originally Posted by Upendra Pratap Singh View Post
If i is to run from 1 up to $(cat text), then $(cat text) must be a value.

Am I wrong if I say this?
You are wrong if the data you have shown is a good representation and you think it should return a number.

The reason the text all appears on a single line is the shell has used the contents of IFS variable to split the data (word splitting) and then echo is presented with
a single line of entries which are space delimited.

Maybe it would help if you showed us the code using the output you are describing? I presume you have not written this code yourself, as if you have it is flawed in its
current format.
 
  


Reply


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
Interpreting lsusb output peanutsmonkey Linux - Newbie 2 06-04-2012 02:08 AM
interpreting output of "du" command? junglepunk Linux - Newbie 11 06-24-2010 04:22 PM
Interpreting dmesg output pwabrahams Linux - Software 2 09-02-2008 01:27 PM
Interpreting output of df -h command kushalkoolwal Debian 1 06-30-2007 07:29 AM
Interpreting the output of 'lspci' command. drminix Linux - Hardware 2 06-14-2005 03:20 AM


All times are GMT -5. The time now is 12:39 AM.

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