Introduction
This article is just an article for showing how to print the content of a file. Printing the content of a file have several ways to achieve it. Normally, there are lots of command available in linux operating system. Simply put, there are ways for printing the content of a file text in every kind of operating system. In this context, it is to print the content of the file into a standard output of terminal. So, in other words, performing the command is done in the command line interface following the output itself will present in that command line interface. The command line interface in this context is a terminal.
Using awk command
In this article, printing the content of a file is possible by using a command with the name of ‘awk’. In the manual page of ‘awk’ command, there is a general information stating that it is a command for pattern scanning and processing language. The following is the basic command pattern of ‘awk’ :
awk '/search_pattern/ { action_to_take_on_matches; another_action; }' file_to_parse
If there is no specific search pattern for further extraction from the file_to_parse, just skip it. On the other hand, there is a value for the part of { another_action }. It is a default action taken if there is no specific pattern matching to the file_to_parse. In this context, the action itself is just to print the content of the file. So, the command for printing the whole content of a file will be just print it using awk. The complete commmand to achieve it exist as follows :
awk '{print}' /proc/meminfo
The command taking for action is ‘print’. It will print the content of the file where the name of the file passing as an example is ‘/proc/meminfo’. The execution of the above command is in the following output :
[root@localhost ~]# awk '{print}' /proc/meminfo MemTotal: 8009408 kB MemFree: 1243420 kB MemAvailable: 4557100 kB Buffers: 2092 kB Cached: 3484704 kB SwapCached: 0 kB Active: 3691920 kB Inactive: 2802972 kB Active(anon): 3008476 kB Inactive(anon): 16484 kB Active(file): 683444 kB Inactive(file): 2786488 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 0 kB SwapFree: 0 kB Dirty: 16 kB Writeback: 0 kB AnonPages: 3008096 kB Mapped: 62556 kB Shmem: 16864 kB Slab: 169500 kB SReclaimable: 130348 kB SUnreclaim: 39152 kB KernelStack: 5312 kB PageTables: 10676 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 4004704 kB Committed_AS: 5670456 kB VmallocTotal: 34359738367 kB VmallocUsed: 22488 kB VmallocChunk: 34359707388 kB HardwareCorrupted: 0 kB AnonHugePages: 2754560 kB CmaTotal: 0 kB CmaFree: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 92016 kB DirectMap2M: 4102144 kB DirectMap1G: 6291456 kB [root@localhost ~]#
As in the output of the above command, the command itself will print the content of the ‘/proc/meminfo’.