LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 05-02-2010, 10:58 PM   #16
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192

Quote:
The bottom line is i am using the command to extract data twice.
In order to assign them to a different variables
Sorry I must be missing what you mean here

Why would you extract the same data twice??
I understand assigning to two different variables, but that would just be:
Code:
a=$data
b=$data
Quote:
they are on different columns after cleaning: column1 and column2, i was trying but i think it is not possible.
Here you mention two columns, maybe if you would give another example like the one on Post #4 so I can see what you mean.
As for "not possible", o ye of little faith. I may not be able to solve it, but I am sure someone can
 
Old 05-03-2010, 09:49 AM   #17
patolfo
Member
 
Registered: Jan 2006
Distribution: Debian-Sarge r2-k.2.6.8-2.386
Posts: 101

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Ok... lets put some data

Code:
a non useful header
a non useful header
string
      stringsomething
            lots of ah
            lots of ah
                      meaningful data
            lots of ah
            lots of ah
                      stringsomething
meaningful data
--non useful tail
--non useful tail
and spaces and tabs of course for a finishing touch
After processing with:
Code:
lista=$(sed -n '/^'"$1"'/,$p' $2 | sed '/'"$1"'|ah|-/ d')
I got
Code:
meaningful data
meaningful data
meaningful data
meaningful data
meaningful data
meaningful data
A string and a scalar, the first column is a name, and the second is the data, a value.
Problem is i need both of them, not only one as i originally thought, so
i have to do this:
Code:
$name_of_socket=$(sed -n '/^'"$1"'/,$p' $2 | sed '/'"$1"'|ah|-/ d' | awk '{print $1}')
$socket_value=$(sed -n '/^'"$1"'/,$p' $2 | sed '/'"$1"'|ah|-/ d' | awk '{print $2}')
It is the same command, kind of repetitive
 
Old 05-03-2010, 09:57 AM   #18
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Or:
Code:
name_of_socket=${lista[0]}
socket_value=${list[1]}
Note: Be carefule about placing $ at the fron of your variable assignments, it will not work as expected.
 
  


Reply



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] BASH: sed question worm5252 Programming 5 03-26-2010 03:33 PM
bash scripting question, homework related cybergeek11235 Linux - General 4 10-12-2008 10:59 PM
bash related question Menestrel Linux - Newbie 2 01-25-2005 10:03 AM
bash related question MattSmith Linux - General 1 01-20-2004 05:41 AM
bash - sed question pk21 Programming 2 07-11-2003 03:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:33 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
Open Source Consulting | Domain Registration