Removing '." character using SED


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Removing '." character using SED
# 1  
Old 06-03-2008
Removing '." character using SED

HI All,

Have some files which contains some string like,

"create .<table1> as"
"insert into .<table2> values",

i want to replace ".<table1>" with only "<table1>", i.e removing '.' character in ksh, i have written below code but it is not removing the dot character, any help?

for name in `cat $filename`;
do
sed 's/\.$name/$name/g' $name > temp; mv -f temp $name;
done


where $filename contains list of files.

Thanks in advance.
# 2  
Old 06-03-2008
Code:
echo " .namish is kumar tiwari" | sed s'/\.namish/namish/'
namish is kumar tiwari

Thanks
# 3  
Old 06-03-2008
You have the same problem with the shell variables, which are in single quotation marks where they can't be substituted by the shell. Have a look in this other thread; there is a small example how to fix this:
https://www.unix.com/shell-programmin...i-morning.html
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed random \n for "n" range of character occurrences

I'd like to put paragraph breaks \n\n randomly between 5 - 10 occurrences of the dot character (.), for an entire text file. How to do that? In other words, anywhere between every 5 -10 sentences, a new paragraph will generate. There are no other uses of the (.) except for sentence breaks in... (11 Replies)
Discussion started by: p1ne
11 Replies

2. Shell Programming and Scripting

sed removing extra character from end

Hi, Searching through forum I found "sed 's/*$//'" can be used to remove trailing whitespaces and tabs from file. The command works fine but I see minor issue as below. Can you please suggest if I am doing something wrong here. $ cat a.txt upg_prod_test upg_prod_new $ cat a.txt |sed... (11 Replies)
Discussion started by: bhupinder08
11 Replies

3. Shell Programming and Scripting

Using sed to find text between a "string " and character ","

Hello everyone Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies

4. Shell Programming and Scripting

sed escape character for comment string "/*"

Good afternoon all, I'm hoping my newbie question can help bolster someone's street_cred.sh today. I'm trying to "fingerprint" SQL on its way into the rdbms for a benchmarking process (so I can tie the resource allocation back to the process more precisely). To do this, I'm essentially... (4 Replies)
Discussion started by: toeharp
4 Replies

5. Shell Programming and Scripting

How to print range of lines using sed when pattern has special character "["

Hi, My input has much more lines, but few of them are below pin(IDF) { direction : input; drc_pinsigtype : signal; pin(SELDIV6) { direction : input; drc_pinsigtype : ... (3 Replies)
Discussion started by: nehashine
3 Replies

6. UNIX for Dummies Questions & Answers

SED + "tab" character

hi all, i would like your help with the "sed" command GIVEN a file with the following format, let s say : In the house, there are no.PCs 3 WHAT i would like to do is to replace the value "3" with another number IF i type the sed command like this : sed 's/'no.PCs3'/'no.PCs1'/g' >... (6 Replies)
Discussion started by: OneDreamCloser
6 Replies

7. UNIX for Advanced & Expert Users

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

8. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

9. Shell Programming and Scripting

Removing a character using sed

Hi, I have a file with the text below. How do i remove the character "%" from the text file using sed ? Can anybody help ? 0% 68% 72% 0% 54% 33% 75% 24% 6% 59% 77% 77% 33% (6 Replies)
Discussion started by: Raynon
6 Replies

10. Shell Programming and Scripting

removing the "\" and "\n" character using sed or tr

Hi All, I'm trying to write a ksh script to parse a file. When the "\" character is encountered, it should be removed and the next line should be concatenated with the current line. For example... this is a test line #1\ should be concatenated with line #2\ and line number 3 when this... (3 Replies)
Discussion started by: newbie_coder
3 Replies
Login or Register to Ask a Question