Reputation: 71
I have XYZ=/opt/Ind
and certain directories under /opt/Ind
I sorted the directories by : ls -t $XYZ
Then I need to get only the size of the first folder.
I tried
du -sk $(ls -t $XYZ/TAL/ | head -n 1)
It gives me this error
du: cannot access `\033[0m\033[01;34m20160525_033732\033[0m': No such file or directory
Will be glad for the help.
Upvotes: 1
Views: 479
Reputation: 290305
The problem here is that you are not using the normal ls
but an alias, so that it provides you some coloured output. This way, instead of a normal name 20160525_033732
you get it with the blue colour.
$ echo -e "\033[0m\033[01;34m20160525_033732\033[0m"
20160525_033732
Just use \ls
to use the original ls
without any alias.
du -sk "$(\ls -t $XYZ/TAL/ | head -n 1)"
# ^
See what the alias is with:
type ls
It will probably return something like:
ls is aliased to `ls --color=always'
Upvotes: 2
Reputation: 2187
add --color=never
to the ls so it won't colorize the output:
du -sk $(ls --color=never -t $XYZ/TAL/ | head -n 1)
Upvotes: 0