LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 02-07-2007, 07:20 AM   #1
MC1903
LQ Newbie
 
Registered: Feb 2007
Location: Hampshire, UK
Distribution: VMware ESX 3.0.1 (RHEL 4?)
Posts: 2

Rep: Reputation: 0
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
 
Old 02-07-2007, 07:38 AM   #2
rizhun
Member
 
Registered: Jun 2005
Location: England
Distribution: Ubuntu, SLES, AIX
Posts: 268

Rep: Reputation: 47
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.
 
Old 02-07-2007, 07:41 AM   #3
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 52
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.
 
Old 02-07-2007, 09:51 AM   #4
MC1903
LQ Newbie
 
Registered: Feb 2007
Location: Hampshire, UK
Distribution: VMware ESX 3.0.1 (RHEL 4?)
Posts: 2

Original Poster
Rep: Reputation: 0

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

 
Old 02-07-2007, 12:53 PM   #5
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 52
gedit
nedit
kate

vim

Yes, bad characters can create problems
 
Old 02-07-2007, 04:20 PM   #6
wpn146
Member
 
Registered: Jan 2005
Distribution: Solaris, Linux Fedora Core 6
Posts: 170

Rep: Reputation: 30
If the editor is designed for MSDOS style of line termination (<cr><lf>) the <cr> will mess up a script.
 
  


Reply

Tags
export, fdisk, sed


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
Sed commands Gins Programming 13 03-31-2006 02:29 PM
sed and escaping & in something like: echo $y | sed 's/&/_/g' prx Programming 7 02-03-2005 11:00 PM
Abut sed and tr commands pazvant Programming 1 05-09-2004 05:20 AM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM
alias and export commands in modules.comf liguorir Linux - Software 1 06-26-2003 07:38 PM


All times are GMT -5. The time now is 03:17 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration