I have directory which has 5 files names test1, test2, test3, test4, test5
Now i want to read file by file and generate md5checksum.
Command used is
md5sum test1.
How can i read file names one after the other and generate checksum and send the output to a file.
Please reply
Is always a bad idea. It's inefficient, since it involves forking another shell and exec'ing ls. Worse, if any of the ls output contains file or directory names which contain IFS characters (space/tab/newline by default), they'll be mangled. Just use a simple glob in this case; it's faster and not subject to field-splitting breakage.