Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 06-10-2008, 02:33 PM   #1
LQ Newbie
Registered: Jun 2008
Posts: 29

Rep: Reputation: 15
how to get the desired output from the following code:


r=$(grep '^Layout' vdat.txt | awk '{print $3}')
echo $r

the above gives out put

how do i get from the output the first word RAID-5 into a variable for comparison

please help me as soon as poosible.. am a newbie

Old 06-10-2008, 02:51 PM   #2
Senior Member
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,402
Blog Entries: 1

Rep: Reputation: 65
You already solved the problem, not in the best way possible, but you did.
Just use the same construction again !

s=$(echo $r | awk '{print $1}')
ok, you want to know an another way ?
you can use an array of variables and print an element using the array index (starting with zero)...

r=($(grep '^Layout' vdat.txt | awk '{print $3}'))
echo ${r[0]}


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
rsync error: errors selecting input/output files, dirs (code 3) at main.c(323) cucolin@ Linux - Networking 3 11-20-2007 05:56 PM
how to set the right charset (or desired) amimusa Debian 1 04-05-2007 04:07 AM
output is the code itself aditya1 Programming 13 03-28-2006 02:29 PM
Desired delay in potfix hotrodowner Linux - Software 2 03-11-2005 06:37 AM
gedit output code linmix Linux - Software 1 01-03-2005 08:07 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:57 AM.

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