Will be watching the much awaited movie tomorrow, getting the same feeling that I got as a kid before the show for the original Jurassic Park..
Will be watching the much awaited movie tomorrow, getting the same feeling that I got as a kid before the show for the original Jurassic Park..
We know how to truncate a table in SQL,i.e. retain the structure of the table removing the contents of the table.
In UNIX ,lets say we want to remove the contents of the file and retain the empty file (zerobyte file). How can we achieve this.
➡ One way is to delete the file completely and recreate it.
➡The second method is to open the file using an editor such as vi and delete each line and save.
But what if we want to truncate the file on the fly?
Consider the problem statement:
Check if the file called dataflow has been sent by upstream and count the number of records. If records exceed threshold (value of 10,000) truncate the file and FTP it to the remote server indicating threhold breach-incorrect records. Else FTP the file as it is.
UNIX has a command for this:
We can use
cat >dev >null dataflow
This would make the file zero byte
A simple hueristic for the above problem will be
If exists file then
If
wc -l dataflow gt threshold
cat >dev >null dataflow
Ftp servername (pick credentials from .netrc)
Put dataflow
Bye
Else
Ftp file intact.
In the next posts time and time I will brush up some important Unix related stuff that can be used as a quick reference. These are some important commands,info that are dug from the grounds of Unix. And hence gems
"INTRO"
23 years back Jurassic Park was sensation. People had never seen anything like it on the screen before. Spielberg achieved a seemingly impossible task and the movie won the hearts of one and all.. And what followed was a mass histeria on dinosaurs with dino toys, dino games,dino theme parks and dino themed movies.
The concept of cloning the extinct giants from DNA of fossilized insects was innovative and the visual effects were phenomenal unlike some of the older hollywood dino flicks where the animals were mere puppets. Here the technicians had breathed life into the animals such that they looked so real.. We as children believed that they were real dinosaurs -We werent aware that the original concept was by an author called Michael Chricton. As time passed by the movie attained cult status.
...continued