output awk print to two separate files

2

Here is my current code

md5sum filename.iso | awk '{print $1} {print $2}'

This gives me two separate lines. The first line is the md5 of the file and the second line is the name of the file. I would like to save the md5 to md5.txt and the name of the file to name.txt The output of md5sum is xxxxxxx filename

J4204144

Posted 2014-08-10T07:52:58.620

Reputation: 144

Answers

1

An easy way is to use redirection, and you don't need to create two actions, you can put both of them in the same one, like:

md5sum filename.iso | awk '{ print $1 > "md5.txt"; print $2 > "name.txt" }'

Birei

Posted 2014-08-10T07:52:58.620

Reputation: 2 744