Re: Script to search an input file, insert a line and then update the file



hiddenmarkov@xxxxxxxxx schrieb:

Hi,
Could any expert out there give me a hint / command used or even a
sample code in writing a script which can perform the function in the
subject line, i.e. read in a file, search for specific string, if the
string is found, insert a line and then close the file? Any suggestion
is appreciated.

NewB.

This sounds like 'in-place-edit'. Allthough it's not pure "shell", it's
quite good, to know these kind of oneliners:

perl -pi.bak -e 's/(search-patters)/$1(inserted-text)/' input_file

Best Regards
Ralf

.



Relevant Pages

  • Program To Pattern Match
    ... I'm looking for a built-in program, aside from writing the obvious ... one/two line script, that does this: ... Where program would return 0 if match was successful. ... was a 'grep' that accepts a string instead of a file/stream. ...
    (comp.unix.shell)
  • Re: eval() or call_user_func() ???
    ... script (not a string). ... I am writing a simplified 'clone' of crontab, ... tasks - the tasks vbeing stored in a database table - I'm not ...
    (comp.lang.php)
  • "Type mismatch" error in JScript - newby question
    ... I'm trying to create a simple text file that will allow a string of text to ... The script firstly creates the text file, ... to then open that file for writing into it, I keep on getting a "type ... Prev by Date: ...
    (microsoft.public.scripting.jscript)
  • Re: Weird timing results with string concatenation & StringStream
    ... > see from the short sample code below I am writing a string to a StringStream ... potential source of variance. ...
    (borland.public.delphi.language.objectpascal)
  • Script to search an input file, insert a line and then update the file
    ... sample code in writing a script which can perform the function in the ... subject line, i.e. read in a file, search for specific string, if the ...
    (comp.unix.shell)