LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-11-2015, 08:18 PM   #1
ShadeLover
LQ Newbie
 
Registered: Apr 2015
Location: Tampa, FL
Posts: 3

Rep: Reputation: Disabled
Question variable expansion and pathname expansion


Hello!

I'm in an online Intro to Unix class. We are using Fedora 20 with VirtualBox. Obviously, as this is for a class, I would normally ask the teacher. But it is an online class, and my professor generally waits a week or so before answering emails.

My question is this: What is the difference between variable expansion and pathname expansion?

I'm supposed to write a script that demonstrates that variable expansion occurs before pathname expansion. I've looked at the BASH Manual for every reference of variable expansion and pathname expansion, and two paragraphs that are in the textbook.

I think that variables on the command line are expanded first normally?

Any help would be so greatly appreciated!
 
Old 04-11-2015, 11:28 PM   #2
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
It clearly says first variable expansion and at the last pathname expansion.
 
Old 04-12-2015, 02:41 PM   #3
ShadeLover
LQ Newbie
 
Registered: Apr 2015
Location: Tampa, FL
Posts: 3

Original Poster
Rep: Reputation: Disabled
expansion

Quote:
Originally Posted by veerain View Post
It clearly says first variable expansion and at the last pathname expansion.
Which it? It says that variable expansion comes first and then pathname? Is there a better information source that explains this more plainly?
 
Old 04-12-2015, 08:49 PM   #4
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by ShadeLover View Post
My question is this: What is the difference between variable expansion and pathname expansion?

I'm supposed to write a script that demonstrates that variable expansion occurs before pathname expansion. I've looked at the BASH Manual for every reference of variable expansion and pathname expansion, and two paragraphs that are in the textbook.

I think that variables on the command line are expanded first normally?
Have a look at the bash manpage, specifically the section EXPANSION:

Code:
       Expansion is performed on the command line after it has been split into words.  There are
       seven kinds of expansion performed: brace expansion, tilde expansion, parameter and vari‐
       able  expansion, command substitution, arithmetic expansion, word splitting, and pathname
       expansion.

       The order of expansions is: brace expansion, tilde  expansion,  parameter,  variable  and
       arithmetic  expansion  and  command  substitution (done in a left-to-right fashion), word
       splitting, and pathname expansion.

       On systems that can support it, there is an additional expansion available: process  sub‐
       stitution.
There is also a subsection for each type of expansion, definitely more than two paragraphs...

Here's a couple of sites that you might find useful:

http://mywiki.wooledge.org/BashGuide
http://wiki.bash-hackers.org/start
 
1 members found this post helpful.
Old 04-14-2015, 09:30 PM   #5
ShadeLover
LQ Newbie
 
Registered: Apr 2015
Location: Tampa, FL
Posts: 3

Original Poster
Rep: Reputation: Disabled
Smile

Thank you Diantre!
 
Old 04-22-2015, 07:22 PM   #6
azazalolxd
LQ Newbie
 
Registered: Nov 2013
Distribution: John
Posts: 1

Rep: Reputation: Disabled
Test, just a test

Hello. And Bye.
 
Old 04-22-2015, 10:56 PM   #7
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,934
Blog Entries: 45

Rep: Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169Reputation: 3169
Moderator response

@azazalolxd this is not a constructive post to this thread. You have been a member since 2013. I suggest that you re-read LQ Rules so that you can post in the correct manner.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash: ${} shamelessly saved from pathname expansion romagnolo Linux - General 2 02-20-2012 04:25 PM
Some help with variable expansion please jakev383 Programming 6 12-06-2011 01:35 PM
variable expansion in bash coolhandluke1 Programming 4 01-09-2008 03:45 PM
bash: strange problem with pathname expansion frankie_DJ Programming 2 01-14-2007 07:16 PM
Scripting help -- pathname expansion player_2 Programming 3 08-25-2003 05:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:27 AM.

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
Open Source Consulting | Domain Registration