LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 08-05-2004, 10:32 AM   #1
ericcarlson
Member
 
Registered: Jan 2002
Posts: 161

Rep: Reputation: 30
Newbie bash path parse problem


In a bash file, say I have a string $fqpath containing /usr/local/oh/what/a/newbie.
I want to parse it and assign a variable to be just the last part, the word "newbie". Something like:

foldername = echo '$fqpath' | gawk #....huh!! what goes here??
echo $foldername
 
Old 08-05-2004, 10:38 AM   #2
Demonbane
LQ Guru
 
Registered: Aug 2003
Location: Sydney, Australia
Distribution: Gentoo
Posts: 1,796

Rep: Reputation: 47
basename $fqpath
 
Old 08-05-2004, 11:32 AM   #3
ericcarlson
Member
 
Registered: Jan 2002
Posts: 161

Original Poster
Rep: Reputation: 30
Yeah! Cheers (but while your here...!)

How do I get the results of a few piped commands into a var I can then use?
Something like

echo 'pwd' | gawk `BEGIN ...df.df. | some other command | more... | variable
echo $variable

!!!

Please !!! Thanks
 
Old 08-05-2004, 11:38 AM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Don't mean to steal Demonbane's glory ...

Code:
variable=$( command1 | command2 | command3 | ... | commandn )
 
Old 08-05-2004, 11:43 AM   #5
ericcarlson
Member
 
Registered: Jan 2002
Posts: 161

Original Poster
Rep: Reputation: 30
Wonderful, thanks!

Hey I understand it too! Nice one.
 
  


Reply


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
Parse String in a Bash script jimwelc Linux - Newbie 8 11-09-2012 08:47 AM
How to parse full path of file name in bash ? hq4ever Programming 2 03-28-2005 04:31 PM
bash script help to parse out text slack guy Linux - Newbie 3 12-30-2004 09:42 AM
BASH search path problem neilcpp Programming 4 02-07-2004 03:04 PM
newbie compile problem: parse errors reetep Programming 8 01-09-2004 11:40 AM


All times are GMT -5. The time now is 09:53 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration