Tag Info

New answers tagged

1

There is no simple generic solution as it is shell dependent: For tcsh or bash: echo .[^.]* For ksh: echo .* However, it will fail in Nykakin's case (files beginning with ..) For a more generic answer, use "grep" or "find", like in: ls -a|grep '^\.\(..\|[^\.]\)' This works with all shells I know and doesn't have the Nykakin's case. Also works with ...


0

a way (but may choke or have side effects on strange filenames, ie files whose name contain a newline! but also files containing * or a " or ... you get the picture ^^. Be very careful if using those way to list and use files) $ for i in * .* ; do echo $i ; done | egrep -v '^\.$|^\.\.$' > /tmp/list_files_one_by_lines $ while read a_file ; do echo ...


4

With tcsh 6.17.01 and above: set globdot du -s -- * With older ones: du -s -- * .[^.]* ..?* (interestingly, that works better than its POSIX counterpart (* .[!.]* ..?*) because in tcsh (and in zsh in csh emulation (cshnullglob option)), contrary to POSIX shells, those pattern that don't match any file get expanded to nothing instead of themselves) ...


2

I usually use: du -ks * .[^.]* This way . and .. are not matched and it should be fairly portable.


1

Not sure if there is a tcsh builtin, but depending on the version of find you have, there is a workaround like this: find -maxdepth 1 -not -name '.' -exec du -s '{}' '+' If your find doesn't do the -exec COMMAND {} + syntax, you can try for -print0/xargs: find -maxdepth 1 -not -name '.' -print0 | xargs -0 du -s


2

You can use ls -A command to not enlist . and .. inside command substitution: echo "`ls -A`"


0

you must be knowing that Directory is nothing but a file that points to some list of files, basically it is a pointer, may be hidden or not. in similar way . and .. are the pointer which point to Uppermost directory and upper directory respectively. that is why i think when we execute ls -a command, these are displayed!


7

. and .. are hard links to the current and the parent directory (/ is the parent of itself). With the -a option ls shows all inodes in the current directory, i.e. also the hidden files which filenames begin with ad dot, therefore . and .. are shown.



Top 50 recent answers are included