Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merging files

Status
Not open for further replies.

Orandajin

Programmer
Mar 2, 2003
2
NL
Hi,

I just started AWK, so i don't know much about it.

I have a tool which merges two new files and a old file (if it exists). The file created can be downloaded (ftp). This works fine and can't be changed.

I want to manipulate the file created so that when it's empty (after merging) it should hold a line with "empty file". It can happen that the file is not being downloaded in time and has a "empty file" line before a new merging occurs, so when the new files are not empty, it should be removed. Also i want to end up with one "empty file" line, in case the new files are also empty.

I hope i made it clear,

thanks in advance

 
Orandajin,

I have not taken the time to code this up but in general terms here are the steps.

1 - Check for the number of lines being zero
lcnt=$(wc -l < yourfilename)

yourfilename can be subsituted with a positional
variable, but the key is the redirection will set
lcnt to the value that you can then do the comparison
against.

2 - Create an if then statement that checks the valuve of
lnct being equal to 0, if it is then append the text
desired to your file prior to the merge otherwise do
nothing.


I can create the code for this if it is still needed.

I hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top