Print the content of multiple differently named files in Linux
November 25, 2021 Leave a comment
If the number of files you are working on is big, then you need automation as soon as possible.
This post describes find -o
option, which helps you work on differently named files when their number is big.
For example, if you want to output the content of files physical_block_size
and logical_block_size
located under /sys/block/*/queue
, run the following:
# find /sys/block/*/queue -name physical_block_size -o -name logical_block_size | while read f ; do echo "$f $(cat $f)" ; done .. /sys/block/dm-0/queue/physical_block_size 4096 /sys/block/dm-0/queue/logical_block_size 512 /sys/block/dm-1/queue/physical_block_size 512 ...
Where -o
means OR.
Useful when working on ASM disks.