Home
Man
Search
Today's Posts
Register

BSD, Linux, and UNIX shell scripting Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Replace String without using sed

Tags
replace, replace string, sed, shell scripts, string

Login to Reply

 
Thread Tools Search this Thread
# 15  
Old 4 Weeks Ago
On Linux you can relink the deleted file with ln -L.
Code:
HIST_DATE="1900-01-01T00:00:00.000Z"
INC_DATE="2018-10-04T09:18:43.000Z"
fn=/tmp/file.tst
{
if rm $fn
then
  sed "s/$HIST_DATE/$INC_DATE/" >$fn ||
  ln -L /proc/$$/fd/1 $fn
fi
} <$fn

Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Search for a string,delete the line and replace with new string in a file Pradhikshan UNIX for Dummies Questions & Answers 10 09-29-2015 05:45 AM
HPUX find string in directory and filetype and replace string pure_jax Shell Programming and Scripting 13 12-17-2012 09:35 AM
sed or awk command to replace a string pattern with another string based on position of this string vivek d r Shell Programming and Scripting 10 06-19-2012 10:35 AM
replace (sed?) a string in file with multiple lines (string) from variable jforce Shell Programming and Scripting 2 09-15-2011 11:10 AM
Search a string in the file and then replace another string after that position dashing201 UNIX for Dummies Questions & Answers 4 06-10-2011 08:45 AM
Using sed to replace a string in file with a string in a variable that contains spaces vivelafete Shell Programming and Scripting 2 11-24-2009 09:43 AM
awk - replace number of string length from search and replace for a serialized array otrotipo Shell Programming and Scripting 1 07-10-2009 01:04 PM
Search, replace string in file1 with string from (lookup table) file2? gstuart Shell Programming and Scripting 9 06-08-2009 07:11 AM
Search for a string and replace the searched string in the same position in samefile ganesh_248 UNIX for Dummies Questions & Answers 27 03-23-2009 01:35 AM
Search for a string and replace the searched string in the same position ganesh_248 Shell Programming and Scripting 15 02-09-2009 09:35 PM


All times are GMT -4. The time now is 12:03 PM.

Unix & Linux Forums Content Copyright 1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password