I should echo only names of files or directories with this construction:
ls -Al | while read string
do
...
done
ls -Al
output :
drwxr-xr-x 12 s162103 studs 12 march 28 12:49 personal domain
drwxr-xr-x 2 s162103 studs 3 march 28 22:32 public_html
drwxr-xr-x 7 s162103 studs 8 march 28 13:59 WebApplication1
For example if I try:
ls -Al | while read string
do
echo "$string" | awk '{print $9}
done
then output only files and directories without spaces. If file or directory have spaces like "personal domain" it will be only word "personal".
I need very simple solution. Maybe there is better solution than awk.
ls -Al *' '*
? Parsingls
's output never leads to anything good. – manatwork Mar 30 '13 at 15:01ls -Al | while
. A simple and more reliable way is `for string in ; do echo "$string"; done`. – forcefsck Mar 30 '13 at 15:17ls
? Parsingls
and "work in all *nix and will not break if something happened" do not go well together. – terdon Mar 30 '13 at 15:59"personal domain"
, how is the substring"personal"
useful? And if you want to filter out the additional information other than the name, why are you using the-l
option? – Keith Thompson Mar 04 '15 at 21:24A1
, notAl
. – greatvovan Jun 28 '19 at 23:29