0

What is the meaning of:

for i in *; do echo *; done

I am on Unix Terminal (Mac OS X)

Darwin localhost 13.1.0 Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014;

2 Answers 2

1

It's a bit redundant. In both places, the * will expand to every file in the current directory. So the loop will repeat once for every file, with i set to a different file name each time. Then the body will simply output the name of every file, ignoring i. So if you have 10 files in the directory, you'll print all 10 file names 10 times.

Sign up to request clarification or add additional context in comments.

Comments

0

many special symbol are used under unix shell,for about bash.

* represent all file name under current directory which split by space,you can use echo * for a test.

~ represent you home directory.

! used for history command.

# for the comment.

$ used for recognize variable

% used for jobs

^ used for history command,format as '^string1^string2^' to quick substitution.

& used for background job

* all file name under current directory which split by space.

() cooperate with $,$(command) equivalent with `command`,$((1 + 2)) calculate mathematic expression like expr command do.

- used for old pwd,you can use 'cd -' back to the directory you switch from.

= use for assignment.

you code

for i in *; do echo *; done

just a for loop print all file name under current directory.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.