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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
02-07-2007, 07:20 AM
|
#1
|
|
LQ Newbie
Registered: Feb 2007
Location: Hampshire, UK
Distribution: VMware ESX 3.0.1 (RHEL 4?)
Posts: 2
Rep:
|
Problems with the export & sed commands... Unexpected respose returned..!
Hi,
First time here - please be patient with me...
I am having problems getting the export command to work as I expect it should... I have less than 1% Linux know-how and I am really struggling...
If I run:
Code:
fdisk -l /dev/cciss/c0d0 | grep fb | sed -e "s/\/dev\/cciss\/c0d0p\(.\).*/\1/"
directly on the command line, I get the expected response of 6 back.
But when I try the full command:
Code:
export VMFS_PARTITION=`fdisk -l /dev/cciss/c0d0 | grep fb | sed -e "s/\/dev\/cciss\/c0d0p\(.\).*/\1/"`
the actual command ( fdisk -l /dev... ) and not the response ( 6 ) is saved in the $VMFS_PARTITION variable.
I would be eternally grateful if someone can let me know what am I doing wrong?
Martin
|
|
|
|
02-07-2007, 07:38 AM
|
#2
|
|
Member
Registered: Jun 2005
Location: England
Distribution: Ubuntu, SLES, AIX
Posts: 268
Rep:
|
Have you tried $()?
export VMFS_PARTITION=$(fdisk -l /dev/cciss/c0d0 | grep fb | sed -e "s/\/dev\/cciss\/c0d0p\(.\).*/\1/")
Don't see why it would make a difference, but its worth a try!
Also, try single quotes instead of double quotes on that sed command.
Last edited by rizhun; 02-07-2007 at 07:39 AM.
|
|
|
|
02-07-2007, 07:41 AM
|
#3
|
|
Senior Member
Registered: Sep 2005
Location: Out
Posts: 3,307
Rep:
|
Strange. Which shell are you running? (echo $0 will tell you)
I modified a bit your line to
export SWAP_PARTITION=`fdisk -l /dev/hda | grep swap | sed -e "s/\/dev\/hda\(.\).*/\1/"`
echo $SWAP_PARTITION
5
It works.

|
|
|
|
02-07-2007, 09:51 AM
|
#4
|
|
LQ Newbie
Registered: Feb 2007
Location: Hampshire, UK
Distribution: VMware ESX 3.0.1 (RHEL 4?)
Posts: 2
Original Poster
Rep:
|
Hi,
Thankyou both for your quick replies... I used Rizhun's $() method and it worked first time...
echo $0 returns -bash
I am wondering if I should use a different text editor - perhaps I had a rogue character/code - any suggestions? I am using NotePad++ at the moment...
Once again, Thankyou.
Martin
|
|
|
|
02-07-2007, 12:53 PM
|
#5
|
|
Senior Member
Registered: Sep 2005
Location: Out
Posts: 3,307
Rep:
|
gedit
nedit
kate
vim
Yes, bad characters can create problems
|
|
|
|
02-07-2007, 04:20 PM
|
#6
|
|
Member
Registered: Jan 2005
Distribution: Solaris, Linux Fedora Core 6
Posts: 170
Rep:
|
If the editor is designed for MSDOS style of line termination (<cr><lf>) the <cr> will mess up a script.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:51 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|