Insert a special character $ in place of extra spaces


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Insert a special character $ in place of extra spaces
# 1  
Old 06-07-2010
Insert a special character $ in place of extra spaces

Hi Experts,

I have called some.txt with the following content.

Code:
oracle            HYRDSRVIHUB01       pts/0                               TESTIHUB                07-JUN-10 CREATE                         TABLE 
             TESTIHUB                       PHONE                                         create table phone ( name varchar2(30), Nber number, type varchar2(20) ).

Now i want to remove extra spaces and replace with $ symbol in between them.

I have used tr -s ' ' < some.txt to remove extra spaces but unable to substitute any $ with extraspace.

My desired out put is :
Code:
oracle$HYRDSRVIHUB01$pts/0$TESTIHUB$07-JUN-10$CREATE$TABLE$TESTIHUB$PHONE$create table phone ( name varchar2(30), Nber number, type varchar2(20) ).

Can you please me.

Regards
Naree

Last edited by Scott; 06-07-2010 at 05:54 AM.. Reason: Code tags, removed a lot of spaces for readability
# 2  
Old 06-07-2010
Code:
sed "s/  */$/g"

# 3  
Old 06-07-2010
It doesn't append $ after the date:

Code:
naresh@HYRDSRVIHUB01:~/test> sed "s/    */$/g" some.txt
oracle$HYRDSRVIHUB01$pts/0$TESTIHUB$07-JUN-10 CREATE$TABLE$TESTIHUB$PHONE$create table phone ( name varchar2(30), Nber number, type varchar2(20) ).

Can please help me.

Regards
Naree.

Last edited by Scott; 06-07-2010 at 09:05 AM.. Reason: Code tags, please...
# 4  
Old 06-07-2010
You have 4 spaces here:
Code:
"s/    */$/g"

There should only be 2
Code:
"s/  */$/g"

And PLEASE use code tags.
# 5  
Old 06-07-2010
Helo, in this place there is a spanish section. How I go in there. Thank

Last edited by Scott; 06-07-2010 at 09:28 AM.. Reason: Do NOT post private email addresses. Thank you
# 6  
Old 06-07-2010
Still not working.

Code:
naresh@HYRDSRVIHUB01:~/test> cat testihub.log | grep 07-JUN-10 | sed "s/  */$/g"
oracle$HYRDSRVIHUB01$pts/0$TESTIHUB$07-JUN-10$CREATE$TABLE$TESTIHUB$SHOP$create$table$shop$($proname$varchar2(30),$price$number,$stock$number$)$


Last edited by Scott; 06-07-2010 at 10:12 AM..
# 7  
Old 06-07-2010
But in your example there does seem to be a $ after 07-JUN-10 , no?

Oherwise try:
Code:
sed "s/[[:space:]]\{1,\}/$/g" infile

or:
Code:
sed "s/[ \t]\{1,\}/$/g" infile

or
Code:
sed "s/[ \t][ \t]*/$/g" infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep string causes extra spaces

Hello, I have an xml file and my aim is to grab each line in keywords file and search the string in another file. When keyword is found in xml file,I expect the script to go to previous line in the xml file and grab the string/value between two strings. It's almost working with an error. tab... (6 Replies)
Discussion started by: baris35
6 Replies

2. UNIX for Advanced & Expert Users

Replace certain character at specific place with related character

hello i have file with 100k records and each one has certain value that starts at 28th column and certain value that starts at 88th column e.g. 1st file <25>1234567 ..... <88> 8573785485 i have aditional file with values which are related to value that starts at 88th column of the... (1 Reply)
Discussion started by: dell1520
1 Replies

3. Shell Programming and Scripting

Delete Numbers, Spaces, Special Character from the begining of the line of a file

Hi All, I want to keep the name of the songs with their respective extensions only. Sample Code ======== 03 Choti choti gaiya choti choti gaval.mp3 03---Brazil Dhol.mp3 03 PAYALIYA .mp3 04 - Isq Risk .mp3 04%20-%20Oh%20My%20Love(wapking.in).mp3 08 - A2 - Aasan Nahin Yahan .mp3 AE... (3 Replies)
Discussion started by: Pramod_009
3 Replies

4. Shell Programming and Scripting

Remove blank space and insert special character

Hi Folks, I have a huge data of the below format abc #apple 1200 06/23 ghj #orange 1500 06/27 uyt #banana 2300 05/13 efg #vegetable 0700 04/16 After first 3 letters, i have 9 spaces and after fruit there are no specific fixed space, but it varies... (4 Replies)
Discussion started by: jayadanabalan
4 Replies

5. Shell Programming and Scripting

Insert underscore in place of column

Hi I tried to put underscore in place of column in a big file with lots of oclumns using the programm sed 's//_/g' Its showing error bash-3.2$ sed 's//_/g'saradrugbankgenedrugnewlist.txt >saradrugbankgenedrugnewlist3.txt sed: -e expression #1, char 11: unknown option to `s' if... (24 Replies)
Discussion started by: manigrover
24 Replies

6. Shell Programming and Scripting

Insert comma in place of column

Hi all, I have a file in which I have to insert commna between entries of 2 column and createa new file separated by commas not a columns if input is FHIT Adenosine Monotungstate Not Available CS Trifluoroacetonyl Coenzyme A Not Available Theo expected output is ... (5 Replies)
Discussion started by: manigrover
5 Replies

7. Shell Programming and Scripting

How to insert a character in line in Special condition?

Hi, I have a log file generated by a tool which has the following look : /tmp/releases/directory/datefilename1_release_date.zip /tmp/releases/directory/datefilename2_release_date.zip /tmp/releases/directory/datefilename3_release_date.zip... (8 Replies)
Discussion started by: bhaskar_m
8 Replies

8. Shell Programming and Scripting

remove extra spaces between fields

Hi, I have a source file as mentioned below: I want to remove all the extra spaces between the fields. a b--------|sa df-------|3232---|3 sf sa------|afs sdf-----|43-----|33 a b c------|adfsa dsf---|23-32|23 *Here '-' idicates spaces Now, I want output as below: a b|sa df|3232|3... (7 Replies)
Discussion started by: srilaxmi
7 Replies

9. Shell Programming and Scripting

How to insert a string in a file at specified place?

Hi all, I want to insert a string in a specified place of a very large file. I am giving an example of the task: I love football. Above is a sentence in a file and I want to insert a string "the" between love and football. It is not sure that where this particular line exists. It has to... (4 Replies)
Discussion started by: naw_deepak
4 Replies

10. Shell Programming and Scripting

adding lines at special place in crontab

Hi , i export the crontab in a file (i've no root right) and i would add lines from a file at a special place and rewrite the output in an another file. the special place is as this : 45 04 * * * /home/toto.sh > /dev/null 2>&1 # so i would search for toto.sh and insert the lines , the... (5 Replies)
Discussion started by: Nicol
5 Replies
Login or Register to Ask a Question