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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get filesize and checksum of spooled file in a log file ...
# 1  
Old 12-06-2011
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;
Code:
a.dat, 2567, 123abcdef.
b.dat, 3456, 789defg35.

...

Thanks for your help,
Emre

Last edited by methyl; 12-06-2011 at 05:27 PM.. Reason: please use code tags
# 2  
Old 12-06-2011
the cksum command, when given a list of files or filenames with * or ? gives the output you want

Code:
cksum ?.dat > mycksumfile.dat

# 3  
Old 12-06-2011
See the "man" page for the unix "cksum" command.
This command outputs the fields in the following order:
Code:
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.

Last edited by methyl; 12-06-2011 at 05:44 PM.. Reason: addenda and typos and layout
# 4  
Old 12-06-2011
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;
Code:
cksum $file > log_file.txt


Last edited by Franklin52; 12-07-2011 at 03:28 AM.. Reason: Please use code tags for code and data samples, thank you
# 5  
Old 12-06-2011
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 >>.
This User Gave Thanks to Corona688 For This Post:
# 6  
Old 12-06-2011
Thanks, ">>" it works.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Checksum different For Same file Created By Two processes

I have one utility in VB which generates attached file(circle.14.mdn_range.properties_VB) & i have created other file(circle.14.mdn_range.properties_UTLFILE) having same contents with UTL_FILE(Oracle running on solaris). But checksum is different for both the files with same contents. Can you... (7 Replies)
Discussion started by: siramitsharma
7 Replies

2. Programming

Perl - Moving file based upon filesize in folder

Hi I'm trying to look through a series of directories in A folder, lets just call it A: for example: A/1 A/2 A/3 Etc and I wish to move the files in the folder if they are bigger than a certain size into a structure like below: A/TooBig/1 A/TooSmall/1 A/TooBig/2 A/TooSmall/2... (1 Reply)
Discussion started by: PerlNewbRP
1 Replies

3. Shell Programming and Scripting

Needed script to FTP a File and generate a quality checksum file

hi all i want a script to FTP a file and should generate a quality checksum file means when I FTP a file from one server to another server it should generate a QC file which should contain timestamp,no.of records in that file Thanks in advance saikumar (3 Replies)
Discussion started by: hemanthsaikumar
3 Replies

4. Shell Programming and Scripting

In Outlook spooled file data is not getting displayed properly

I am fetching a database table in spool file and send that details as a email. The Spooled file content is properly being displayed in UNIX. See Example below : ID|FILENAME |ABCDEF_DT |PROCESSED_DT |STATUS... (4 Replies)
Discussion started by: Ravi_007
4 Replies

5. UNIX for Advanced & Expert Users

Checksum with file permissions and dates ?

find . \! -type p -exec cksum {} \; >> check.out Okay i was able to get the checksum of the files of the directory and sub directories..how do I get the list with the checksum and the file permissions and dates in the same file...now this is driving me crazy...can anyone help me with this ? ls... (3 Replies)
Discussion started by: moe458
3 Replies

6. Shell Programming and Scripting

Need help in finding filesize , moving file , gzipping file

Hi , Please help with the following questions 1) how can i find size of a file ? i have written du -k $flname > s1 . Is this right ? Any other better suggeastions ? 2) how do I use mv command for moving the file ? I need the syntax with some examples 3) Command for printing the total... (1 Reply)
Discussion started by: Learning!
1 Replies

7. UNIX for Dummies Questions & Answers

spooled file getting distorted when sending through unix mail

Hi Folks, I'm spooling a file through sqlplus and sending using mailx but the output got distorted in MS-outlook. Thanks in advance (2 Replies)
Discussion started by: chgopi
2 Replies

8. Shell Programming and Scripting

Capture output of program to file with limited filesize

I'm working on a script that will perform a backup, save a log of said backup and send the output to me in an email. Everything is working fine so far except that I can't figure out how to specify a maximum file size for the log file. I don't want a runaway log file jamming up the server.... (7 Replies)
Discussion started by: spectre_240sx
7 Replies

9. UNIX for Dummies Questions & Answers

filesize from a file which has the list of files.

i have a file myfile. it has the below entries /temp/firstfile /temp/secondfile and many more.. okay, now, i want to addup all the space occupied by this file hmmm, but i met with a problem in getting each file out. i did a silly command like more myfile | grep temp | ls -ltr and it... (3 Replies)
Discussion started by: yls177
3 Replies

10. UNIX for Advanced & Expert Users

Directory where spooled file is stored

I am spooling a text file to printer under Sun Solaris m/c (solaris 7). I want to know which directory the spooled text file is stored before it goes to printer. B'se my main problem is to find the escape sequence from the text file to get landscape orientation. Now when ever I spool a file... (1 Reply)
Discussion started by: babulilly
1 Replies
Login or Register to Ask a Question