0

When I set a name for a file like "project report.pdf" and list it via a for loop and $@ method, I see the name of the file separately like "project" in one row and "report.pdf" in another row. How can I see this file in one row? I need an output like "project report.pdf" after the code that I mentioned. What should I do?

set $(ls)
for i in $@
do
echo $i;
done

Output of this code:

project
report pdf
tripleee
  • 175,061
  • 34
  • 275
  • 318
Murcielago
  • 45
  • 7

1 Answers1

0

The ls is useless You can do this simply with

printf '%s\n' *

More generally, see When to wrap quotes around a shell variable?

tripleee
  • 175,061
  • 34
  • 275
  • 318