Removing lines from a file being used by another process using SHELL script
Hi All,
Need a small help in writing a shell script which can delete a few lines from a file which is currently being used by another process.
File gets appended using tee -a command due to which its size is getting increased.
Contents like :
My requirement is to remove lines which are more than 1 month old...
for this i will cut month from the line i.e. 09 and backtrack to fetch the previous value i.e. 8
and remove all lines from top till the row fetched...
Query is can i remove the lines in the same file ? (what if another process comes to write in that file using tee -a)..
Thanks,
Nik
Last edited by Scrutinizer; 09-25-2012 at 04:39 AM..
Reason: code tags
hi i'm new to shell scripts and have a small problem
i am running a batch converter that returns all flash .flv files in a directory and create a png image from each one
the problem i have is the $1 variable , its ok on the first call but on the secound call $1.png , i have extra... (1 Reply)
I need to remove the entire file contents in file using the shell script.
Actually the grap -v command will create one more file and it occupy the space also.
I need to remove the entire file contents without creating new file using the shell scripting.
Please help me. (5 Replies)
Hey all. I am trying to write some scripts and need some assistance.
One:
I already have a script that appends lines to a file. I need a script that will remove those lines from that file, and have no idea how to go about doing this. Just need the command (if any) that can remove lines.
... (2 Replies)
The file starts like this:
Directory: <path to the script>
Script: <script fife name>
#!bin/ksh
##Comments
<actual script>
What is the use of the first two lines in the script? What if I save the file without them? What will be the effect? They are not comments. Im very new to this,... (4 Replies)
I want to make a config file which contain all the paths.
i want to read the config file line by line and pass as an argument on my below function.
Replace all the path with reading config path line by line and pass in respective functions.
how can i achieve that?
Kindly guide.
... (6 Replies)
Hi All, Looking for a quick LINUX shell script which can continuously monitors the flle size, report the process which is creating a file greater than certain limit and also kill that process. Can someone please help me on this? (4 Replies)
I wish to by pass a process if the file is over a certain size?
not sure this makes sense
current bit of the script below
#if we are bypAssing the OCR
if ; then
echo Bypassing HOTFOLDER OCR
HOT_FOLDER_DIR=$BATCH_POST_OCR_DIR;
potential change below? would this work would I need... (1 Reply)
Hello,
I have a src code file where I need to uncomment many lines.
The lines I need to uncomment look like,
C CALL l_r(DESNAME,DESOUT, 'Gmax', ESH(10), NO_APP, JJ)
The comment is the "C" in the first column. This needs to be deleted so that there are 6 spaces preceding "CALL".... (7 Replies)
Discussion started by: LMHmedchem
7 Replies
LEARN ABOUT DEBIAN
io::tee
Tee(3pm) User Contributed Perl Documentation Tee(3pm)NAME
IO::Tee - Multiplex output to multiple output handles
SYNOPSIS
use IO::Tee;
$tee = IO::Tee->new($handle1, $handle2);
print $tee "foo", "bar";
my $input = <$tee>;
DESCRIPTION
"IO::Tee" objects can be used to multiplex input and output in two different ways. The first way is to multiplex output to zero or more
output handles. The "IO::Tee" constructor, given a list of output handles, returns a tied handle that can be written to. When written to
(using print or printf), the "IO::Tee" object multiplexes the output to the list of handles originally passed to the constructor. As a
shortcut, you can also directly pass a string or an array reference to the constructor, in which case "IO::File::new" is called for you
with the specified argument or arguments.
The second way is to multiplex input from one input handle to zero or more output handles as it is being read. The "IO::Tee" constructor,
given an input handle followed by a list of output handles, returns a tied handle that can be read from as well as written to. When
written to, the "IO::Tee" object multiplexes the output to all handles passed to the constructor, as described in the previous paragraph.
When read from, the "IO::Tee" object reads from the input handle given as the first argument to the "IO::Tee" constructor, then writes any
data read to the output handles given as the remaining arguments to the constructor.
The "IO::Tee" class supports certain "IO::Handle" and "IO::File" methods related to input and output. In particular, the following methods
will iterate themselves over all handles associated with the "IO::Tee" object, and return TRUE indicating success if and only if all
associated handles returned TRUE indicating success:
close
truncate
write
syswrite
format_write
formline
fcntl
ioctl
flush
clearerr
seek
The following methods perform input multiplexing as described above:
read
sysread
readline
getc
gets
eof
getline
getlines
The following methods can be used to set (but not retrieve) the current values of output-related state variables on all associated handles:
autoflush
output_field_separator
output_record_separator
format_page_number
format_lines_per_page
format_lines_left
format_name
format_top_name
format_line_break_characters
format_formfeed
The following methods are directly passed on to the input handle given as the first argument to the "IO::Tee" constructor:
input_record_separator
input_line_number
Note that the return value of input multiplexing methods (such as "print") is always the return value of the input action, not the return
value of subsequent output actions. In particular, no error is indicated by the return value if the input action itself succeeds but
subsequent output multiplexing fails.
EXAMPLE
use IO::Tee;
use IO::File;
my $tee = new IO::Tee(*STDOUT,
new IO::File(">tt1.out"), ">tt2.out");
print join(' ', $tee->handles), "
";
for (1..10) { print $tee $_, "
" }
for (1..10) { $tee->print($_, "
") }
$tee->flush;
$tee = new IO::Tee('</etc/passwd', *STDOUT);
my @lines = <$tee>;
print scalar(@lines);
AUTHOR
Chung-chieh Shan, ken@digitas.harvard.edu
COPYRIGHT
Copyright (c) 1998-2001 Chung-chieh Shan. All rights reserved. This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
SEE ALSO
perlfunc, IO::Handle, IO::File.
perl v5.12.3 2001-03-10 Tee(3pm)