Ubuntu – Needed simple script/loop/command for input command, execute and output within textfiles

command lineexecute-commandscripts

Suppose I have list of commands in text file as below (cat cmdlist.txt):-

cut
lshw
top
awk
sensors

Now I want to get simple information on that command by whatis cut, whatis lshw etc. respectively and print these out-put of whatis <commadnd> in text file say cmdinfo.txt

Desired output of cmdinfo.txt (cat cmdinfo.txt):-

cut (1)              - remove sections from each line of files
lshw (1)             - list hardware
top (1)              - display Linux processes
awk (1)              - pattern scanning and text processing language
sensors (1)          - print sensors information

How do I achieve cmdinfo.txt file with output of whatis for commands from cmdlist.txt Respectively?

This is only sample txt files.

Suggest simple script if needed.

Best Answer

As simple as possible:

xargs whatis < cmdlist.txt > cmdinfo.txt
Related Question