sed removing extra character from end


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed removing extra character from end
# 8  
Old 03-23-2015
Try
Code:
TAB=$(printf "\011")
sed "p;s/[ $TAB]$//" file

# 9  
Old 03-23-2015
Code:
sed 's/'"$spc"'*$//' a.txt

Worked for me .. Thanks !!

---------- Post updated at 08:41 AM ---------- Previous update was at 08:40 AM ----------

Thanks RudiC/MadeInGermany for your time :-)
# 10  
Old 03-23-2015
A general solution that should work with any (POSIX) sed (and independent of the capabilities of the shell it runs in) would be:
Code:
sed 's/[[:blank:]]*$//' a.txt


Last edited by Scrutinizer; 03-24-2015 at 01:37 AM..
# 11  
Old 03-23-2015
Quote:
Originally Posted by Scrutinizer
A general solution that should work with any (POSIX) sed would be:
Code:
sed 's/[[:blank:]]*$//' a.txt

Will it be able to remove tabs as well?
# 12  
Old 03-23-2015
Quote:
Originally Posted by bhupinder08
Will it be able to remove tabs as well?
Yes.
This User Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - Removing extra character when setting variable

I have a data file d0 that looks like this: $cat d0 server1 running -n-cv- 8G 3.1% 1435d 15h server2 running -n---- 8G 39% 660d 22h server3 running -n--v- 8G 2.5% 1173d 6h server4 running -n---- 8G 1.1% 1048d 20h... (2 Replies)
Discussion started by: jake0391S
2 Replies

2. Shell Programming and Scripting

sed - Removing all characters from token to end of line

Hello. The token is any printable characters between 2 " . The token is unknown, but we know that it is between 2 " Tok 1 : "1234x567" Tok 2 : "A3b6+None" Tok 3 : "A3b6!1234=@" The ligne is : Line 1 : "9876xABCDE"Do you have any code fragments or data samples in your post Line 2 : ... (3 Replies)
Discussion started by: jcdole
3 Replies

3. Shell Programming and Scripting

sed removing until end of line

All: Can somebody help me out with a sed command, which removes the the first occurance of ')' until the end of the line If I have the following input ... (5 Replies)
Discussion started by: BeefStu
5 Replies

4. UNIX for Dummies Questions & Answers

Removing end of line using SED

Hello Friends, How can I remove the last two values of this line using sed John Carey:507-699-5368:29 Albert way, Edmonton, AL 25638:9/3/90:45900 The result should look like this: John Carey:507-699-5368:29 Albert way, Edmonton, AL 25638 (3 Replies)
Discussion started by: humkhn
3 Replies

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

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

7. Shell Programming and Scripting

How to get rid of extra enter at the end???

Hi guys, I want to automate a few tasks. For one of them, I need to get the output of a command and parse it to extract information I need: drbdadm create-md drbd0 The output is: md_offset 48010952704 al_offset 48010919936 bm_offset 48009453568 Found ext2 filesystem which uses... (2 Replies)
Discussion started by: alirezan
2 Replies

8. Shell Programming and Scripting

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... (2 Replies)
Discussion started by: arvindcgi
2 Replies

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

10. Shell Programming and Scripting

Removing character from list line (at the end)

Hi, I have file as shown below. abc, def, abc, xyz, I have to remove ',' from end of last line (xyz,). How can I do that with single command? Is it possible or I have to iterate through complete file to remove that? - Malay (2 Replies)
Discussion started by: malaymaru
2 Replies
Login or Register to Ask a Question