Basically I get line from ls -la command:
-rw-r--r-- 13 ondrejodchazel staff 442 Dec 10 16:23 some_file
and want to get size of file (442). I have tried cut and sed commands, but was unsuccesfull. Using just basic UNIX tools (cut, sed, awk…), how can i get specific column from stdin, where delimiter is / +/ regexp?
If you want to do it with
cutyou need to squeeze the space first (tr -s ' ') becausecutdoesn’t support+. This should work:It’s a bit more work when doing it with
sed(GNU sed):Slightly more finger punching if you use the grep alternative (GNU grep):