Removing selectively the last character from a file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Removing selectively the last character from a file
# 1  
Old 09-09-2009
Removing selectively the last character from a file

Dear Members,

Quote:
I have a file whose last character is "\". I need to remove this character.
Problem is suppose i have 50 lines in a file, 40 lines last character is "\" and the remaining 10 lines are good(i mean these 10 lines do not have "\" character)

How can i remove this character from the file.

Thanks
# 2  
Old 09-09-2009
Code:
sed 's#[\]$##' myFile

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing last character of a specific line from a file

Hello guys, I would need to remove the last character ")" of a specific line. This can be from any line. Your help is appreciated. Below is the line. HOSTNAME=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)) Please help. (6 Replies)
Discussion started by: sang8g
6 Replies

2. Shell Programming and Scripting

How to remove spaces from a file selectively?

Hi i have a file in which i am doing some processing. The code is as follows: #!/bin/ksh grep DATA File1.txt >> File2.txt sed 's/DATA//' File2.txt | tr -d ‘ ‘ >> File4.xls As you can see my output is going in a xl file.The output consist of four columns/feilds out of which the first... (20 Replies)
Discussion started by: Sharma331
20 Replies

3. Shell Programming and Scripting

Script for removing newline character from file

Hi below is my file. cat input.dat 101,abhilash,1000 102,prave en,2000 103,partha,4 000 10 4,naresh,5000 (its just a example file) and my output should be: 101,abhilash,1000 102,praveen,2000 103,partha,4000 104,naresh,5000 below is my code cat input.dat |tr -d '\n' >... (6 Replies)
Discussion started by: abhilash_nakka
6 Replies

4. UNIX for Dummies Questions & Answers

Need help removing last character of every line if certain character

I need help removing the last character of every line if it is a certain character. For example I need to get rid of a % character if it is in the last position. Input: aaa% %bbb ccc d%dd% Output should be: aaa %bbb ccc d%dd I tried this but it gets rid of all of the % characters.... (5 Replies)
Discussion started by: raptor25
5 Replies

5. Shell Programming and Scripting

Removing Special Character from File.

Hi, My file has this special character "^M" I would like to remove this characters. eg: abc,abc,^M i tried using sed but doesnt work. i used octal dump command to see special character it returns following: 015 \r Appreciate your reply. (6 Replies)
Discussion started by: pinnacle
6 Replies

6. UNIX for Dummies Questions & Answers

Removing ^@ character at the end own belowof Linux file

Hi, I have a Linux file which has content as sh (0 Replies)
Discussion started by: bhuvanas
0 Replies

7. Shell Programming and Scripting

Removing ^Z Character in a File

Hi, I am having a pipe (|) delimited file which is having ^Z character in the middle of the text.Could anyone please suggest me how to remove this ^Z Character from the file.I almost used all the ideas posted in this site but none of them worked in my case since tis ^Z character is not coming at... (4 Replies)
Discussion started by: phoenix86
4 Replies

8. UNIX for Advanced & Expert Users

Selectively Reformating a file using AWK

Dear users, I am new to AWK and have been battling with this one for close to a week now. Some of you did offer some help last week but I think I may not have explained myself very well. So I am trying again. I have a dataset that has the following format where the datasets repeat every... (5 Replies)
Discussion started by: sda_rr
5 Replies

9. Shell Programming and Scripting

Removing last character from each line of file

How can I remove the last character from each line of a file? This must be done without "funny" characters, as I want to transfer the code to/from Windows. Any ideas? (17 Replies)
Discussion started by: cjhancock
17 Replies

10. UNIX for Dummies Questions & Answers

removing a character and addending to end in each line in a file

HI i am having a file this (sys19:pnlfct:/pfact/temp>) cat temp_sand 1234567890 1234567890 1234567890 1234567890 I want to make this file as (sys19:pnlfct:/pfact/temp>) cat temp_sand 1456789023 1456789023 1456789023 1456789023 just take the 2nd and 3rd position and put it... (5 Replies)
Discussion started by: arunkumar_mca
5 Replies
Login or Register to Ask a Question