Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi All,
My SUn UNIX doesn't support "-i" option for sed which edits file in place
I don't want to use intermidiate temp file to delete lines from file & write the same into original filee.g.
I don't want
sed '/text/d' file1 > temp
mv temp file1I am looking for alternative for
sed -i '/text/d' file1Kindly replay if anybody has solution

Thanks nails & james.
But what i am looking for is -
I have, say 3 functions which runs in background
All functions are editing single text file to insert/update one line of record.If i use perl , then i can not delete line from it as i am serching apttern first & deleting whole line.
Other option i tried is sed && mv
But again it is creating problem as text file gets overwirttenIf anybody can help me further?
Thanks

By this statement "3 functions runs in background" I'm assuming you have 3 different shell scripts or programs operating on the same text file.
The only way I can see that this will work is if one job finishes before the next one starts. In Unix, this functionality is implemented with a semaphore - something not normally implemented in shell scripts.
You might want to check out "Implementing Semaphores in the Shell":
http://www.samag.com/documents/s=92...Maybe a semaphore can help you out.
There's a companion article that builds on top of the semaphore article called "Queuing jobs with qjobs":

Thanks nail..
But i have 3 functions in same shell script.
Okay ..i will check the given links
in meantime can you please tell me whats wrong in below line.
Bcoz it seems to solve my purpose#!/usr/bin/bash
RUN=R1
filename=f1
perl -p -i -e 's/qq{$RUN}/\|\d\d\d\d\|[A-Z]*/R3/i' $filenameI am expecting $RUN to be expanded by shell
Also plz note my file f1 is like this
R1|1000|SUCCESS
and i am replacing it by
R3Thanks again

hey ! i got the solution & its working
perl -p -i -e "S/$RUN/\|\d\d\d\d\|[A-Z]*/R3/i" $filename
Thanks

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |