New answers tagged

2

Put this shell function declaration in your shell initialization scripts: function duls { paste <( du -hs -- "$@" | cut -f1 ) <( ls -ld -- "$@" ) } I called it duls because it shows the output from both du and ls (in that order): $ duls 210M drwxr-xr-x 21 kk staff 714 Jun 15 09:32 . $ duls * 36K -rw-r--r-- 1 kk staff 35147 Jun ...


1

I have managed to do what you want with some rather complex sed calls:- ls -d Directory/*|while l="$(line)";\ do s=$(du -sb "$l"|sed "s/^\([0-9]*\).*$/\1/"); ls -ld "$l"|\ sed "s/^\(d[^ ]* *[^ ]* *[^ ]* *[^ ]* \) *[^ ]* /\1\[$s\] /g";\ done Note:- I have put square brackets round the directory sizes, to distinguish them from the file ...


1

ls -l will show you the sizes of files within a directory. du -sh * will show you the size of the directories.


-1

If you read the man of ls command, you'll see there’s a -h option, which shows you in human readable type the size of each file inside a directory.


0

The easiest way is probably to use the mdls command. mdls lists the metadata attributes for a specified file. Here is a sample output for a .png file I have on my Desktop $ mdls ~/Desktop/hipchat.png _kMDItemOwnerUserID = 205009058 _kTimeMachineIsCreationMarker = 1 _kTimeMachineNewestSnapshot = 4001-01-01 00:00:00 +0000 ...


0

check the value of the LC_COLLATE environment variable. If set to "POSIX", it should do the 'alphabetical sort' in all cases.


0

I have come up with a Bash script that should work to make this happen. # Automatically do an ls after each cd cd() { if [ -n "$1" ]; then builtin cd "$@" && ls --group-directories-first else builtin cd ~ && ls --group-directories-first fi }



Top 50 recent answers are included