Latest LQ Deal: Linux Power User Bundle
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 08-05-2004, 10:32 AM   #1
Registered: Jan 2002
Posts: 162

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
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
Registered: Jan 2002
Posts: 162

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
Senior Member
Registered: Jan 2003
Posts: 2,786

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

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

Original Poster
Rep: Reputation: 30
Wonderful, thanks!

Hey I understand it too! Nice one.


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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:18 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