I have not tested the following, but it is a viable theory:
when sed (and presumably perl too) modifies a file it has to create an intermediate file. This is because of its modus operandi: it reads from the source file, modifies the read part and writes this modified version to the target file (screen or new file). This is why you usually do:
although this looks cumbersome. Notice that
won't work, because sed would read the first line, modify it, then write it back to the file it just read from and further tries to read from it now won't be successful any more.
This is why Linux (/GNU-) versions of sed and perl extended the options of the original sed to the "-i" switch, which does just that: automatically replacing the input file and making the second command variant working.
Still this doesn't change the working of sed and the trick with which the "-i" switch is implemented is to create a (hidden) temporary output file and move that over the original file after the modification. In fact "-i" is just automating the "mv"-command in my first example. If you start a long-running sed job you will probably find the intermediate file somewhere in /tmp, /var/tmp or some similar place while the job runs.
It may well be that this doesn't honor soft links because a new file is created and then moved in place, replacing the inode of the softlink.
Hi
We have a requirement to send email using shell script.email should have html body and pdf attachment. We used uuencode for attaching files and sendmail option to acheive and it is working fine. However custoemr wants to make body of email slightly dynamic. E.g dear customer in html file... (3 Replies)
I am having trouble re-writing this sed code
sed -nr 's/.*del(+)ins(+).*NC_0{4}(+).*g\.(+)_(+).*/\3\t\4\t\5\t\1\t\2/p' C:/Users/cmccabe/Desktop/Python27/out_position.txt > C:/Users/cmccabe/Desktop/Python27/out_parse.txt in perl Basically, what the code does is parse text from two fields... (12 Replies)
Hi Guys,
OS:- Solaris 10 64Bit
I have a small query.
On one server a user is facing sed command issue.
He gets error regarding sed for this location
/users/hoy/2999/batch5/bin/internal.sh: /usr/local/bin/sed: not found
How ever the sed is actually present at this location on server:-... (13 Replies)
Hi all,
Hoping someone hoping someone might be able to help. i've got the following sed command which i'm using in a bash script that i'm trying to use to insert a new line into an already existing file so i don't have to manually enter it when setting stuff up. the existing script test2/3 are... (3 Replies)
Hello everyone,
This is my first posting. I have read the rules of this forum. I have searched many various threads and haven't found one that applies to my situation or suggestions to fix the issue. I do appreciate the help.
I am trying to execute a basic UNIX script in a Solaris... (4 Replies)
Help!
I am using sed to convert text files into easily viewed html tables.
I have managed all except converting the email addresses to mailto: links.
Multiple email addresses exist within the files, either preceded by a space or > (as part of HTML tag), and followed by either space or <
I've... (5 Replies)
Hi,
I am modifying a file with sed command. i want to make SCORE= blank in the file whereever SCORE=somevalue.
What will *$ do in the below command?
cat $file | sed 's/SCORE=.*$/SCORE=\r/g' > newfile
The last line is also missing in the new file. How to make SCORE='100' to SCORE=... (5 Replies)
Hello,
Question is related to Perl:
I need to search few of the files from the array of file names.
And after grepping the file names from an array I need to link these files to original location. The original location in this case is ref_path as input from the user.
##$ref_path is... (3 Replies)
I was wondering how I can create a link to the perl interpreter.
On my old machine perl is at: user/local/bin/perl
and my new machine has it at: user/bin/perl
I don't want to have to change all my cgi scripts when I move them to the new server. Can I just create a new directory... (4 Replies)