Sponsored Content
Full Discussion: updates only
Top Forums Shell Programming and Scripting updates only Post 302283339 by otheus on Tuesday 3rd of February 2009 05:44:30 AM
Old 02-03-2009
Can the file change anywhere? Or can lines only be added to it? If lines can only be added to it, just keep track of the last line number:
Code:
wc -l <filename> >/root/lastcheck-line.dat

Then a while later, do:
Code:
read L </root/lastcheck-line.dat
awk "NR==$L,0" <filename>  >/root/temp.txt

Once you're done, you can print the length again. You can do it altogether this way:
Code:
L=1; test -s /root/lastcheck-line.dat && read L </root/lastcheck-line.dat
awk "NR==$L,0 { print } END { print NR >'/root/lastcheck-line.dat' }" <filename>  >/root/temp.txt

 

7 More Discussions You Might Find Interesting

1. AIX

unix updates- Where can I find unix updates online for IBM servers?

I have a Unix based server running Sagitta and the server is giving me an error of 4b10004 and my research tells me this is an EPROM issue, which means the processor needs to be flashed or repaired. Once up and running where can I go to get updates for Unix? (1 Reply)
Discussion started by: crainer
1 Replies

2. UNIX for Advanced & Expert Users

multiple updates

Hi all, I would like to perform multiple updates within a single database open and close. Box: solaris dB: informix This is how i do perform for single update dbaccess <dbname> -<<EOF update table1 set col1=1 where col2=1 EOF i have the col1 values in a file (some 1000 values)... (1 Reply)
Discussion started by: matrixmadhan
1 Replies

3. Red Hat

RedHat Updates

All, I'm updating my redhat servers by directly connecting to internet (redhat network). After I connecting to the internet, I see some packages in package updater.I'm trying to do update but its stucking up when it is starting updating the server. Any ideas. Thanks (4 Replies)
Discussion started by: s_linux
4 Replies

4. UNIX for Dummies Questions & Answers

CentOS updates

hello all I Installed CenTOS 5.5 and i've Run yum update command every thing went smoothly but i got the following error at the end 6:kdebase-3.5.4-21.el5.centos.1.i386: Insufficient space in download directory /var/cache/yum/updates/packages * free 6.0 M * needed 28 M ... (2 Replies)
Discussion started by: abu_shiahb
2 Replies

5. Fedora

Installing updates

Hi, Im using Fedora version 23 (latest upgrade and upates). Currently to receive the updates, I use: su -c 'yum update' This works fine, but I get: yum command has been deprecated, redirecting to '/usr/bin/dnf update'. See 'man dnf' and 'man yum2dnf' for more information. To... (1 Reply)
Discussion started by: Janning
1 Replies

6. Shell Programming and Scripting

Cron updates

This cmd will update the user's crontab with the quoted line. But how to script the update using a previously stored variable? crontab -l | awk '{print} END {print "* * * * * echo test >> /tmp/testing"}' | crontab crontab -l | awk '{print} END {print "$storedvariable"}' | crontab Does not... (3 Replies)
Discussion started by: gtsonoma
3 Replies

7. HP-UX

Software updates?

On Hp-ux,I'm not talking about security patches.But free products like SecureShell. How to know if update is avaliable?On Solaris11 is possible using pkg update. On hpux?Some tool to check for outdated products and tell if new version is avaliable? ---------- Post updated at 03:24 AM... (1 Reply)
Discussion started by: Linusolaradm1
1 Replies
IO::AtomicFile(3)					User Contributed Perl Documentation					 IO::AtomicFile(3)

NAME
IO::AtomicFile - write a file which is updated atomically SYNOPSIS
use IO::AtomicFile; ### Write a temp file, and have it install itself when closed: my $FH = IO::AtomicFile->open("bar.dat", "w"); print $FH "Hello! "; $FH->close || die "couldn't install atomic file: $!"; ### Write a temp file, but delete it before it gets installed: my $FH = IO::AtomicFile->open("bar.dat", "w"); print $FH "Hello! "; $FH->delete; ### Write a temp file, but neither install it nor delete it: my $FH = IO::AtomicFile->open("bar.dat", "w"); print $FH "Hello! "; $FH->detach; DESCRIPTION
This module is intended for people who need to update files reliably in the face of unexpected program termination. For example, you generally don't want to be halfway in the middle of writing /etc/passwd and have your program terminate! Even the act of writing a single scalar to a filehandle is not atomic. But this module gives you true atomic updates, via rename(). When you open a file /foo/bar.dat via this module, you are actually opening a temporary file /foo/bar.dat..TMP, and writing your output there. The act of closing this file (either explicitly via close(), or implicitly via the destruction of the object) will cause rename() to be called... therefore, from the point of view of the outside world, the file's contents are updated in a single time quantum. To ensure that problems do not go undetected, the "close" method done by the destructor will raise a fatal exception if the rename() fails. The explicit close() just returns undef. You can also decide at any point to trash the file you've been building. AUTHOR
Primary Maintainer David F. Skoll (dfs@roaringpenguin.com). Original Author Eryq (eryq@zeegee.com). President, ZeeGee Software Inc (http://www.zeegee.com). REVISION
$Revision: 1.2 $ perl v5.16.2 2005-02-10 IO::AtomicFile(3)
All times are GMT -4. The time now is 07:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy