sed search


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers sed search
# 8  
Old 09-09-2016
Quote:
Originally Posted by Pavan Kumar19
It's generating the output like below.
Code:
$abcd$str$xyz

Expected output is
Code:
$abcd/str.xyz

The output you are showing us looks close to the results we would have expected from the script you showed us in post #3. I would have expected the output from that command to be:
Code:
$abc$st$xyz

instead of:
Code:
$abcd$str$xyz

I think Corona688 had a typo in post #4:
Code:
sed 's/[.]/|$|g' input-file > different-output-file

and intended to use:
Code:
sed 's|[.]/|$|g' input-file > different-output-file

With that change, you should have gotten exactly what you asked for in different-output-file if input-file contained the text you showed us in post #1. And either of Scrutinizer's suggestions in post #6 should also have given you exactly what you wanted if you added the name of an input file to those commands where that input file contained the text from post #1.

What operating system are you using? What shell are you using? Are you absolutely positive that the input file(s) you gave to Corona688's and Scrutinizer's suggestions was the text shown in post #1?
These 2 Users Gave Thanks to Don Cragun For This Post:
# 9  
Old 09-09-2016
Hello Corona688 and Don,

Thanks a lot. What you said is very true. It's working. It was my fault.

Thanks for saving my time.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed -s does not search recursively

I would like to export the 5th line from every file within a directory. I am using GNU sed because we have no Unix or Linux environment. I used the following statement: sed -s -n 5p c:\directory\*.* but I only get the 5th line from one of the files in the directory. I am desperate for a... (1 Reply)
Discussion started by: hollingv
1 Replies

2. Shell Programming and Scripting

Need help with search and replace using SED

Hi guys, thanks for accepting me in your forum .. I am trying to clean some hacked PHP files using SSH .. I am using this command: find . -type f -print0 | xargs -0 sed -i '/god_mod/d' <?php ... (3 Replies)
Discussion started by: wisam74us
3 Replies

3. Shell Programming and Scripting

sed search and wc

I have a file of the following >!#jjdjahfjdhfjkds aklsjdlkasdkashfjkdshfkjdsbfnbsdkjnfbdsk >*kfjhdsafjdshjfkhdsjkfhdsk wuyruiewyrieyueytireuytreyu >-jdfhsjsjkdhfd xzmncxzbvnmcxbvbcxn I would like to do a wc for the lines starting with > For the above example, the result is 3. ... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

4. Shell Programming and Scripting

sed help - search/copy from one file and search/paste to another

I am a newbie and would like some help with the following - Trying to search fileA for a string similar to - AS11000022010 30.4 31.7 43.7 53.8 60.5 71.1 75.2 74.7 66.9 56.6 42.7 32.5 53.3 I then want to replace that string with a string from fileB - ... (5 Replies)
Discussion started by: ncwxpanther
5 Replies

5. Shell Programming and Scripting

Sed - search and replace help.

Hi everyone, basically I am been cleaning data by using simple sed commands So what i have below has been working for me. sed 's/="//g' trade.csv > tradeb.csv sed 's/"//g' tradeb.csv > trade2.csv but now i don't want to remove all the quotes just the ones if i encounter this ... (1 Reply)
Discussion started by: raz0r
1 Replies

6. UNIX for Dummies Questions & Answers

How to use 'sed' to search and replace?

Hello - I have a very large file in which a certain numbers are repeated. I find that using vi to edit the entire file is useless. How should i use sed to find a replace such as this text: To replace: 145.D25.D558 With: 215.22.45.DW I tried this command: sed... (4 Replies)
Discussion started by: DallasT
4 Replies

7. UNIX for Dummies Questions & Answers

SED: Can't Repeat Search Character in SED Output

I'm not sure if the problem I'm seeing is an artifact of sed or simply a beginner's mistake. Here's the problem: I want to add a zero-width space following each underscore between XML tags. For example, if I had the following xml: <MY_BIG_TAG>This_is_a_test</MY_BIG_TAG> It should look like... (8 Replies)
Discussion started by: rhetoric101
8 Replies

8. UNIX for Dummies Questions & Answers

sed search and replace

Hello Folks, Anyone know how I can replace this line in file.xml <oacore_nprocs oa_var="s_oacore_nprocs">8</oacore_nprocs> with this line <oacore_nprocs oa_var="s_oacore_nprocs">1</oacore_nprocs> using sed or awk ? Thanks for your time. Cheers, Dave (7 Replies)
Discussion started by: d__browne
7 Replies

9. Shell Programming and Scripting

Search and replace sed or tr

Hi folks, I need to search and replace specific text in a file and replace it. I have a text file that does not have any newlines or carriage returns. All newlines have been removed. Here is what I need to do. Find the exact string “DH” (quotes included) and replace it with \n”DH” (basically... (6 Replies)
Discussion started by: bridgeje
6 Replies

10. UNIX for Dummies Questions & Answers

Search using sed

May i know how to perform a search using sed? For example, a user enter a string, and i need to search it in a file details.dat to verify it. And additional how to create a auto-generate number? And it can be increment each time a record added? (1 Reply)
Discussion started by: Ohji
1 Replies
Login or Register to Ask a Question