Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.



Question

In linux, use awk to just display the file name, followed by space followed by file size of file in current directory. Note the output of running "ls -lh":

-rw-rw-r-- 1 kevin kevin 8.8K Nov 16 11:28 java_versions_all_instances.xlsx
-rw-r--r-- 1 kevin kevin 6.3K Nov  9 17:24 java_versions_detailed.xlsx

Answer

ls -lh | awk '{print $9 " " $5}'

^^ note the program given to the awk interpretor is wrapped in single quotes

^^^ note that the program block is wrapped in brace brackets

^^^ for the print method of AWK, note that concatenation is done via white-space seperated strings


Question

In linux, use awk to just display the file name, followed by space followed by file size of file in current directory. Note the output of running "ls -lh":

-rw-rw-r-- 1 kevin kevin 8.8K Nov 16 11:28 java_versions_all_instances.xlsx
-rw-r--r-- 1 kevin kevin 6.3K Nov  9 17:24 java_versions_detailed.xlsx

Answer
?

Question

In linux, use awk to just display the file name, followed by space followed by file size of file in current directory. Note the output of running "ls -lh":

-rw-rw-r-- 1 kevin kevin 8.8K Nov 16 11:28 java_versions_all_instances.xlsx
-rw-r--r-- 1 kevin kevin 6.3K Nov  9 17:24 java_versions_detailed.xlsx

Answer

ls -lh | awk '{print $9 " " $5}'

^^ note the program given to the awk interpretor is wrapped in single quotes

^^^ note that the program block is wrapped in brace brackets

^^^ for the print method of AWK, note that concatenation is done via white-space seperated strings

If you want to change selection, open document below and click on "Move attachment"

20. Advanced Shell Scripting
ng language call AWK. A common use for awk is in field stripping. It is slightly more flexible than cut -- cat /etc/passwd | awk -F : '{print $1}' --especially where whitespace gets in the way, <span>ls -al | awk '{print $6 " " $7 " " $8}' ls -al | awk '{print $5 " bytes"}' which isolates the time and size of the file respectively. Get your nonlocal IP addresses with: ifconfig | grep 'inet addr:' | fgrep -v '127.0.0.' | \

Summary

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Details

No repetitions


Discussion

Do you want to join discussion? Click here to log in or create user.