Hi All,
We have a requirement to Create sequential file only if any rows written into it, otherwise no need to create a sequential file.
please let me know you thoughts on how to acheive this task.
Thanks,
Satheesh
Create sequential file only if any rows written into it
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 182
- Joined: Thu Jun 16, 2005 2:05 am
Instead of complicated workaround, put in an after-job call to SH and execute "find . -name {YourFileName} -size 0 -exec rm -f {} \;" . I am sure that the real UNIX experts will suggest a more efifacious command, but this should work well enough.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
or you can create the file with a different name and copy it to your expected output name if the size is greater than 0.
will assist you.
Code: Select all
test -s
I've only used "test -s" in scripts and don't know how it can be used in a single command line to delete zero length files, which is why I reverted to the time-honored and much distinguished "find" command. Do you have an example of how to use "test" without writing or calling a script?
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
Bottom line, Satheesh, is that your sequential file will always be created regardless of how many records are written to it, including zero. So you will either need some kind of 'work around' to fake this (as posted) or just live with and don't worry about it (which is what practically everyone does).
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 182
- Joined: Thu Jun 16, 2005 2:05 am
-
- Premium Member
- Posts: 892
- Joined: Thu Oct 16, 2003 5:18 am