Quick UNIX question - Assigning a word to $model


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Quick UNIX question - Assigning a word to $model
# 1  
Old 07-07-2010
Question Quick UNIX question - Assigning a word to $model

When the following is typed:

Code:
/usr/platform/`uname -i`/sbin/prtdiag | awk '{print $7; exit}'

...the output I get back is either "X4150" or "X4170" when executed on a Sun Fire X4150 or X4170. ---But, may I ask how do I assign the variable $model to it?

Because of the embedded backquotes, I cannot simply say: ...or else I'll get errors, if I tried the below:
Code:
model=`/usr/platform/`uname -i`/sbin/prtdiag | awk '{print $7; exit}'`

...Instead of the wrong way above, may I ask the correct way to assign this 1-word output to $model ? (so I can simply "print $model" to get the answer?)

Thanks,
CG

Last edited by chatguy; 07-07-2010 at 03:38 PM..
# 2  
Old 07-07-2010
Code:
model=$(/usr/platform/`uname -i`/sbin/prtdiag | awk '{print $7; exit}')

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 07-07-2010
Quote:
Originally Posted by bartus11
Code:
model=$(/usr/platform/`uname -i`/sbin/prtdiag | awk '{print $7; exit}')

Thanks, Bartus! That works perfectly!!

Thanks again,
CG
# 4  
Old 07-07-2010
bartus11's solution is better, but your code still works by below way:

Code:
model=`/usr/platform/\`uname -i\`/sbin/prtdiag | awk '{print $7; exit}'`

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Quick UNIX command to display specific lines in the middle of a file from/to specific word

This could be a really dummy question. I have a log text file. What unix command to extract line from specific string to another specific string. Is it something similar to?: more +/"string" file_name Thanks (4 Replies)
Discussion started by: aku
4 Replies

2. UNIX for Dummies Questions & Answers

quick question vi word search

hi, while in vi, we use /string to look for the particular string. after that operation, the particular string is highlighted in yellow color. how do i take the highlight off? thanks so much. (1 Reply)
Discussion started by: hobiwhenuknowme
1 Replies

3. UNIX for Dummies Questions & Answers

Quick question

Hi guys Quick question Im creating an FTP server and im chrooting each user to there home directory blah blah. Ive also setup scponly so there locked etc. Im a novice at unix and have just reaslised the primary group of scponly is the username of one of the ftp users... which im sure... (1 Reply)
Discussion started by: mokachoka
1 Replies

4. Shell Programming and Scripting

Quick question

When I have a file like this: 0084AF aj-123-a NAME Ajay NAME Kumar Engineer 015ED6 ck-345-c 020B25 ef-456-e 027458 pq-890-p NAME Peter NAME Salob Doctor 0318F0 xy-123-x NAME Xavier Arul NAME Yesu Supervisor 0344CA de-456-d where - The first NAME is followed by... (6 Replies)
Discussion started by: ajay41aj
6 Replies

5. Shell Programming and Scripting

quick question

I am using sed to find a pattern in a line and then I want to retain the pattern + the rest of the line. How is this possible? ie: line is: 14158 05-15-08 20:00 123-1234-A21/deliverable/dhm.a search for 123-1234-A21 ie: echo $line | sed 's/.*\(\{3\}-\{4\}-\{3\}\{5\}\).*/\1/' ... (1 Reply)
Discussion started by: phreezr
1 Replies

6. Shell Programming and Scripting

Perl: array, assigning multi-word sentences with quotes

Just wondering if there's a better way to get these complete sentences into an array and keep the quotes intact? All the quotes make it look ugly to me but it works. I want to be able to refer to the full sentences by index. I've tried a few qw and qq/ aproaches but what I have below seems about... (4 Replies)
Discussion started by: gctaylor
4 Replies

7. AIX

quick question

Hi, At best I'm a junior admin with a big problem. My developers have got my root password and mgmt insists they need it. I can't even change it when people knowing it leave. I'm certain they've hardcoded it into routines. I've searched my servers and grepped everything & can't find it. ... (5 Replies)
Discussion started by: keith.m
5 Replies

8. UNIX for Dummies Questions & Answers

Quick question

Hello all, Quick question from a fairly new to Unix developer. if then completedLogFile=$logfile.$(date +%Y%m%d-%H:%M:%S) mv $logfile $completedLogFile fi I understand that this portion of code is simply copying a tmp logfile to a completed logfile when a condition is true. The... (2 Replies)
Discussion started by: JohnnyBoy
2 Replies

9. UNIX for Dummies Questions & Answers

Another quick question

Hi guys sed -e "s/$<//g" the $< can allow me to assign an input value to the variable right? do the double quotes check the previous context? (1 Reply)
Discussion started by: hamoudzz
1 Replies

10. UNIX for Dummies Questions & Answers

A Quick Question

Wat is the difference between the cp mv ln etc in /usr/sbin/static and cp mv ln functions in /usr/bin (4 Replies)
Discussion started by: DPAI
4 Replies
Login or Register to Ask a Question