Computing.Net > Forums > Unix > Unix sed substitute text with / in

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Unix sed substitute text with / in

Reply to Message Icon

Name: jaxler
Date: May 14, 2004 at 20:53:46 Pacific
OS: UNIX
CPU/Ram: 510 MG
Comment:

I have a file (file1.txt) that has the string 08/01/2004 in the middle of it. I need a script (sed?) to write all records from file1.txt to file3.text. I need a script (sed?) to substitute from file2.txt 09/01/2004 (that's the only thing in file2.txt for the 08/01/2004 in file1.txt
before writing to file3.txt

Thanks,
Jim



Sponsored Link
Ads by Google

Response Number 1
Name: Wolfbone
Date: May 15, 2004 at 02:13:04 Pacific
Reply:

sed "s%\([[:digit:]][[:digit:]]/\)\{2\}[[:digit:]]\{4\}%$(cat file2.txt)%" file1.txt > file3.txt


0

Response Number 2
Name: Jim Boothe
Date: May 17, 2004 at 07:10:10 Pacific
Reply:

That would change all dates. To change just the 08/01/2004 string:

sed "s%08/01/2004%$(cat file2.txt)%" file1.txt > file3.txt


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Capture exit codes from U... Input from user



Post Locked

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


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Unix sed substitute text with / in

Unix/dos amending text www.computing.net/answers/unix/unixdos-amending-text/7368.html

Unix sed command problem www.computing.net/answers/unix/unix-sed-command-problem/5822.html

sed substitute '<' in XML text www.computing.net/answers/unix/sed-substitute-amplt-in-xml-text/5246.html