Replacing text


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replacing text
# 1  
Old 07-24-2006
Replacing text

I was using the following code to replace the path names and it works when it is
Code:
echo "$PWD/$f" | sed -e 's/^.*chris\.domain\.com/chris.domain.com/'

IN fact it works great

However I tried to incorporate a variable

echo "$PWD/$f" | sed -e 's/^.*$account\.domain\.com/$account.domain.com/'

And now the output is not working.

Can anyone help.

Chris
# 2  
Old 07-24-2006
Quote:
Originally Posted by chrchcol
echo "$PWD/$f" | sed -e 's/^.*$account\.domain\.com/$account.domain.com/'
Drop the single quotes and introduce " ".

Code:
echo "$PWD/$f" | sed -e "s/^.*$account.domain.com/$account.domain.com/"

You do not have to specifically escape the dot (.)
# 3  
Old 07-24-2006
Thank you so much that worked well.
# 4  
Old 07-25-2006
Problems with find command and time variable

I am using the following
Code:
echo How many hours? 
echo hours
let t=$hours*60

find . -type f -mmin "$t" > holder

Its supposed to find all the files changed in t minutes and put them into the file holder. It does not seem to be working though.

Chris
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replacing text in between the string

Here is just a few variations that follow the same principle. We need to update the path to all images (only images) <IMG src="/3251_8832613.jpg"> <IMG src="https://www.unix.com/images/1303_4703925.jpg"> <IMG src="\\SERVER\DATA\Image\1948_4703925.jpg"> <img... (12 Replies)
Discussion started by: 2by4
12 Replies

2. Shell Programming and Scripting

Replacing text between two patterns

I would like to replace ], with ]]], between /* SECTION2-BEGIN */ and /* SECTION2-END */ in my file. My file contains the following information: /* SECTION1-BEGIN */ , /* SECTION1-END */ /* SECTION2-BEGIN */ , /* SECTION2-END */ /*... (5 Replies)
Discussion started by: azdps
5 Replies

3. Shell Programming and Scripting

Replacing text on every third line

I have file like this "copy table_name from filea.txt on node replace delimiter '|';" "copy table_name from fileb.txt on node replace delimiter '|';" "copy table_name from filec.txt on node replace delimiter'|';" "copy table_name from filee.txt on node replace delimiter '|';" "copy... (1 Reply)
Discussion started by: nnani
1 Replies

4. Shell Programming and Scripting

Replacing grepped text.

Dear Friends, I need your help once again. I have a flat file from which I have grepped something and kept in a separate file for some reason. I want to replace these grepped srtings with the strings in another file. E.g. Actual_file.txt COLOR: 33179 Lakme SEPT2011 Lot No: BR25324 ... (5 Replies)
Discussion started by: anushree.a
5 Replies

5. Shell Programming and Scripting

Replacing text/characters in vi

ok, so i have the following text to replace but it's not working. can someone please help me out: :%s~awk '// {split($2,s,",");a=$1 FS s} /-/ {b=a} END{print b}'~tail -1~g I want to replace the entire awk command with tail -1. thanks (7 Replies)
Discussion started by: SkySmart
7 Replies

6. Shell Programming and Scripting

Matching and replacing text

Im new to using perl scripting, and i was wondering if anyone could help me, I need to create a cgi file that when it runs it opens a file looks through all the words, and replace the word hello with goodbye, ive been looking around and someone said to use an If statement, but ive found no other... (2 Replies)
Discussion started by: xzen123
2 Replies

7. Shell Programming and Scripting

replacing text in a file, but...

Hi all, Very first post on this forums, hope you can help me with this scripting task. I have a big text file with over 3000 lines, some of those lines contain some text that I need to replace, lets say for simplicity the text to be replaced in those lines is "aaa" and I need it to replace it... (2 Replies)
Discussion started by: Angelseph
2 Replies

8. Shell Programming and Scripting

Replacing Text in Text file

Hi Guys, I am needing some help writing a shell script to replace the following in a text file /opt/was/apps/was61 with some other path eg /usr/blan/blah/blah. I know that i can do it using sed or perl but just having difficulty writing the escape characters for it All Help... (3 Replies)
Discussion started by: cgilchrist
3 Replies

9. Shell Programming and Scripting

help required for replacing text in vi

Hi Any one pls give me command in vi to replace /opt/usr with /home/reddy/dump .... i tried escaping / with \ bt its not working... thanks in advance (6 Replies)
Discussion started by: Chandu2u
6 Replies

10. Shell Programming and Scripting

replacing text

hey how can i change part of a file i hve to do in a masses so mv or cp is not practical. I have to change xxx_rrr to xxx_yyy pls help thank (2 Replies)
Discussion started by: ajaya
2 Replies
Login or Register to Ask a Question