Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3618730
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:47:24+00:00 2026-05-18T22:47:24+00:00

Actually, I am fully understand the use of $* and $@. For example, if

  • 0

Actually, I am fully understand the use of $* and $@.

For example, if I run the script using: my_script *

Then, for ONE_FILE in $@ will really get each file into ONE_FILE for processing.
Even there is space(s) in the filenames, ONE_FILE will get the correct filename.

If, however, using for ONE_FILE in $*, the story is different.
I think you guys understand the difference and I do not need to go further.

Now, what I am interested is HOW.
How the KornShell (ksh) interprets the my_scrpt *
and then pass the filenames into $@ correctly
and pass the filenames into $*.

For example, when the ksh see my_script *
, does it put the filenames one by one into an array,
and then put the array[1][2][3]… into $@ for processing ?
And, when seeing $*, does it just concat
filename1+space+filename2+space+… ?

I know that this may relate more to the internal coding of ksh.

Any insight?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T22:47:25+00:00Added an answer on May 18, 2026 at 10:47 pm

    For example, when the korn shell see my_script *, does it put the filenames one by one into an array,
    and then put the array[1][2][3]… into $@ for processing ?
    And, when seeing $*, does it just concat
    filename1+space+filename2+space+… ?

    Yes, pretty much.

    One important thing to realize here are that there are two separate processes involved: the calling shell, which expands my_script * into myscript arg1 arg2 arg3 and the subprocess which gets the array of arguments. If that subprocess is ksh (or sh, bash, or a similar shell) then $* is just syntax for “get argv[1…] as a concatenated string” while $@ is syntax for “get argv[1…] as an array”. It’s also important to note that $* and $@ are only meaningfully different when quoted.

    In bash, a cousin of ksh, this idea of array variables has actually been generalized. (Perhaps ksh has done this too — I haven’t used ksh for about a decade…)

    In bash, this creates an array of 3 elements called a. Note that the first element contains a space:

    [~]$ a=("foo bar" baz quux)
    [~]$ for i in ${a[*]}; do echo $i; done
    foo
    bar
    baz
    quux
    [~]$ for i in ${a[@]}; do echo $i; done
    foo
    bar
    baz
    quux
    [~]$ for i in "${a[*]}"; do echo $i; done
    foo bar baz quux
    [~]$ for i in "${a[@]}"; do echo $i; done
    foo bar
    baz
    quux
    

    As you can see from the example, "${a[*]}" concatenates the array while "${a[@]}" actually gives you the individual elements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand why you would want to use a read-only property using the following
Have you ever worked on a (full-time) project where using Agile methodologies actually allowed
Actually, I'm using this way. Do you have a better way? private bool AcceptJson(HttpRequest
What diagramming technique(s) do you use while programming to help you or others understand
I've been going through the tutorials (specifically ones using Linq-To-Entities) and I understand the
I want to use a view script to render my zend form as it
While I was learning threading memory barrier (fences) seems really not easy to understand,
I'm working on a pretty simple script, reading a maplist.txt file and using the
Being fully self-taught without actually reading up on JavaScript (It's my job now, believe
Actually, this question seems to have two parts: How to implement pattern matching? How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.