Get filesize and checksum of spooled file in a log file ...

Hi All,

I have spooled some data in a file (a.dat, b.dat etc..) and after that I want to get the size and checksum of spooled file (a.dat, b.dat etc..) in a log file(file_info.log).

By the way I dont want lost the previous output file info(Append data).

View of log file that I want to create;

a.dat, 2567, 123abcdef.
b.dat, 3456, 789defg35.

...

Thanks for your help,
Emre

the cksum command, when given a list of files or filenames with * or ? gives the output you want

cksum ?.dat > mycksumfile.dat

See the "man" page for the unix "cksum" command.
This command outputs the fields in the following order:

cksum <filename>
<checksum> <size in bytes> <filename>

Try it.

Then uses the unix Shell redirect ">" to write the output from the command to your log file (after possibly using the "awk" or "cut" commands to change the order of the output).

The question suggests the order of field output from the old unix "sum" command but the file size in this case would be in 512 byte blocks. The unix "cksum" command is much preferred to the unix "sum" command and the unix "cksum" command picks up simple transposition which the old unix "sum" command misses.

Thanks for your response, friends.

cksum <file_name>, it works but in every excution, log file was refreshed. I mean it does not append the new data after previous, always it shows the new file's info.

My Code;

cksum $file > log_file.txt

The idea was to give cksum several filenames in the first place instead of running it n times for n files.

If you want it to append, use >>.

1 Like

Thanks, ">>" it works.