re: removing trailing space from lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting re: removing trailing space from lines
# 1  
Old 06-18-2003
re: removing trailing space from lines

Quote:
Originally posted by sameerbo
Hi,

How can we remove the all trailing spaces of a line from a file.


TiA
Sameer.
Not sure why this thread was closed without any explanation, but you can do what you're asking with sed 's/[[:blank:]]*$//g' < sourceFile > destFile
# 2  
Old 06-19-2003
Thank You! oombera, for answering the query.
I really appreciate your effort to answer, even the closed thread.

I was going through the various threads after posting my query.
there was one thread 'Remove Last Character of Line'. this was pretty similar query. I got the answer for my query from this thread.

And that is why i closed the thread.

I just tried this syntax but it doesn't work. I am working on solaris 5.8. And I am not sure whether this syntax works on other platform. may be this is the case, that, it work on some other platform.

I used this syntax.
---------------------------------------------
sed 's/ *$//g' < file_tailing_spaces
---------------------------------------------
Notice that it has two spaces preceeding '*$'
Actually, I have file which has more than one trailing spaces. It worked.

Thank You! Once Again.
Sameer.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing Trailing Line

I have been trying to remove empty lines and lines just filled with spaces. I have used the following command which does work. sed -i "/^\s*$/d" Except it leaves one single trailing line at the very end of the file. For the life of me I cant figure out why I cant remove that last trailing... (2 Replies)
Discussion started by: user8282892
2 Replies

2. UNIX for Dummies Questions & Answers

Removing trailing x'0A' characters.

I am trying to remove trailing carriage return (x'0a') from a source program. What is a good way to do this for the whole file? TIA (4 Replies)
Discussion started by: wbport
4 Replies

3. UNIX for Dummies Questions & Answers

Removing trailing characters

I have been given a shell script that I need to amend. To do the following extract the filename from the flag file by removing the .flag extension. # Local variables # Find if the flag files exists MASK=coda_mil2*.flag # Are there any files? bookmark="40" fileFound=0 ls -1... (3 Replies)
Discussion started by: andymay
3 Replies

4. Shell Programming and Scripting

Removing just the trailing commas :-(

Hi all, I haven't needed to do any shell based editing for nearly 20 years, and no amount of searching around has found me a solution to this very simple problem :-( I have a csv file. Some lines have three commas at the end. This means the invoice hasn't been paid. I'd like to use sed / grep... (4 Replies)
Discussion started by: chardyzulu
4 Replies

5. UNIX for Dummies Questions & Answers

Removing trailing lines at the end of a text file

How do you remove trailing empty lines at the end of a text file? Thanks! (3 Replies)
Discussion started by: evelibertine
3 Replies

6. UNIX for Dummies Questions & Answers

Removing the trailing date from a filename

Hi I have 3 files (say) in a folder as in the example below abc_01012011.csv def_01012011.csv xyz_01012011.csv I need to move these files to a different folder as follows abc.csv def.csv xyz.csv I am trying to put together a script with a for loop which reads the source filenames... (5 Replies)
Discussion started by: bobsn
5 Replies

7. Shell Programming and Scripting

Removing trailing zeros using sed

Hello All, I have a csv file with 3 columns. The file which looks like this 47850000,100,233 23560000,10000,456 78650000,560000,54 34000000,3456,3 The first column has 4 trailing zeros. I have to remove 4 trailing zeroes from 1st field. The output file should appear as follows. ... (12 Replies)
Discussion started by: grajp002
12 Replies

8. Shell Programming and Scripting

Removing trailing zeroes

So, I can't figure out how to do a previous question with printf, so I'm taking a different approach. Suppose I have a set of numbers: 1200,135.000000,12.30100,3212.3200,1.759403,,1230,101.101010,100.000000 I want to remove all trailing zeroes after the decimal, and, if it ends up orphaned,... (8 Replies)
Discussion started by: treesloth
8 Replies

9. Shell Programming and Scripting

Removing empty lines(space) between two lines containing strings

Hi, Please provide shell script to Remove empty lines(space) between two lines containing strings in a file. Input File : A1/EXT "BAP_BSC6/07B/00" 844 090602 1605 RXOCF-465 PDTR11 1 SITE ON BATTERY A2/EXT... (3 Replies)
Discussion started by: sudhakaryadav
3 Replies

10. Shell Programming and Scripting

sed: removing any and all trailing digits?

We have a large number of oracle database related scripts that utilize the environment variables $ORACLE_SID and $DBNAME. In a single instance database the $ORACLE_SID is the same as the database name $DBNAME. So we have simply set DBNAME = $ORACLE_SID. However, now that we are clustering with RAC,... (5 Replies)
Discussion started by: Squeakygoose
5 Replies
Login or Register to Ask a Question