Replace '$' with no character using tr command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replace '$' with no character using tr command
# 1  
Old 02-24-2011
Replace '$' with no character using tr command

Hi All,
Need your help urgently.

since '$' comes at the end of the line i want to remove '$' using tr command:

file:
Code:
111111|.11|.00$
222222|2.22|.00$
333333|.33|.00$
444444|.44|.00$

Thanks in Advance

Last edited by Franklin52; 02-24-2011 at 05:58 AM.. Reason: Please use code tags, thank you
# 2  
Old 02-24-2011
There is a smiler post discussed recently.

Deleting the last character in a text file

You will need to escape the dollar -- \$
This User Gave Thanks to clx For This Post:
# 3  
Old 02-24-2011
Code:
tr -d '$' < file

# 4  
Old 02-24-2011
Code:
 $ ruby -i -ne 'print $_.sub(/\$$/,"")' file

# 5  
Old 02-24-2011
the $ end of line may also appear if you have the list option enabled in vi editor

to disable when in vi :

<Esc> make sure you switch to command mod
:set nolist to disable the list option
# 6  
Old 02-24-2011
Code:
sed 's/\$$//' infile

# 7  
Old 02-26-2011
Quote:
Originally Posted by jlliagre
Code:
tr -d '$' < file

that would delete all "$" that is not at the end
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Find character and Replace character for given position

Hi, i want find the character '-' in a file from position 284-298, if it occurs i need to replace it with 'O ' for the position in the file. How to do that using SED command. thanks in advance, Sara (9 Replies)
Discussion started by: Sara183
9 Replies

3. Shell Programming and Scripting

sed command to replace a character at last

Hi All, I have a file having one line only. It is like trapsess:inform|10.232.167.18|1|1|50|25|0|0|0|5|1|1|78|0037| I want to replace the numbers in last two columns by As. It should look like trapsess:inform|10.232.167.18|1|1|50|25|0|0|0|5|1|1|AA|AAAA| Please, suggest me any shell... (12 Replies)
Discussion started by: mukeshbaranwal
12 Replies

4. Shell Programming and Scripting

Replace multiple occurances of same character with a single character.

Hi all, Greetings, I have the following scenario, The contents of main file are like : Unix|||||forum|||||||||||||||is||||||the||best so||||||be|||||on||||||||||||||||||||||||||||||||||||||||||||it And i need the output in the following form: Unix=forum=is=the=best so=be=on=it ... (3 Replies)
Discussion started by: dipanchandra
3 Replies

5. Shell Programming and Scripting

In Sed how can I replace starting from the 7th character to the 15th character.

Hi All, Was wondering how I can do the following.... I have a String as follows "ACCTRL000005022RRWDKKEEDKDD...." This string can be in a file called tail.out or in a Variable called $VAR2 Now I have another variable called $VAR1="000004785" (9 bytes long), I need the content of... (5 Replies)
Discussion started by: mohullah
5 Replies

6. Shell Programming and Scripting

replace two character strings by two variables with sed command

Hello, I want to writte a script that replace two character strings by two variables with the command sed butmy solution doesn't work. I'm written this: sed "s/TTFactivevent/$TTFav/g && s/switchSLL/$SLL/g" templatefile. I want to replace TTFactivevent by the variable $TTFav, that is a... (4 Replies)
Discussion started by: POPO10
4 Replies

7. Shell Programming and Scripting

Please help replace character command

hi i have log : i want remove some char become like this: anybody can help me ? (7 Replies)
Discussion started by: justbow
7 Replies

8. Shell Programming and Scripting

script command to replace character

Hi, i have log like this : Actually i want to change the time stamp, and the rule is like this : and My script is like this : I know the script will loop and loop again after 07:00 like this: Can somebody help me ?? Thanks in advance.. (5 Replies)
Discussion started by: justbow
5 Replies

9. Shell Programming and Scripting

read in a file character by character - replace any unknown ASCII characters with spa

Can someone help me to write a script / command to read in a file, character by character, replace any unknown ASCII characters with space. then write out the file to a new filename/ Thanks! (1 Reply)
Discussion started by: raghav525
1 Replies

10. UNIX for Dummies Questions & Answers

Command to replace character

I've been googling for the following for the past few weeks several times, but haven't yet come across something that I could easily grasp. Can someone point me in the right direction please? I'm trying to replace a character in file names, i.e. the character is a period, and I want to replace... (5 Replies)
Discussion started by: HLee1981
5 Replies
Login or Register to Ask a Question