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
I would guess that it depends on how you remove the top lines. This is at the bash prompt...
In the example above, I created a file then submitted a background process to append to the file. Using sed -i to remove the first line didn't work, but awk worked okay.
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)
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)
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 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)
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)
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)
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)
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)