How to remove plank spaces at the end of lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to remove plank spaces at the end of lines
# 1  
Old 12-06-2005
How to remove plank spaces at the end of lines

Hello friends,

I want to remove blank spaces at the end of lines. I use sed command to do this but it is not working correctly.
sed ‘s/ $//’ file_name

Can some body tell me what is the proper way to remove blank spaces at the end of a limes.

Thanks,
Mahesh Fernando.
# 2  
Old 12-06-2005
You should output the results to some file. Only then can you see the changes.
Code:
sed -e 's/ *$//g' file_name > file_name.temp
mv file_name.temp file_name

# 3  
Old 12-06-2005
Are you redirecting your output to another file? That command won't change the file itself.
# 4  
Old 12-06-2005
Friends,

Thanks for the correction.

I am rederectiong the file. given syntax is working fine.


Thanks,
Mahesh.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove lines having older end time

Hi, In my bash script I want to add a code which remove all entries older than x days. To simplify this problem, I have divided into 3 parts. (2 parts are done looking answer for 3rd part.) To find the latest log date - Done Latest_Time=`find . -name '*.tps' -exec sed '/endTime/!d; s/{//;... (3 Replies)
Discussion started by: Agoyals1986
3 Replies

2. Shell Programming and Scripting

Remove duplicate lines after ignoring case and spaces between

Oracle Linux 6.5 $ cat someStrings.txt GRANT select on MANHPRD.S_PROD_INT TO OR_PHIL; GRANT select on MANHPRD.S_PROD_INT TO OR_PHIL; GRANT select on SCOTT.emp to JOHN; grant select on scott.emp to john; grant select on scott.dept to hr;If you ignore the case and the empty space between the... (6 Replies)
Discussion started by: kraljic
6 Replies

3. UNIX Desktop Questions & Answers

To remove the extra spaces at the end of each line in a file

I have a file of about 10k records and eace line is having an extra space of 5 byte at the end.. Iwant to remove the extra spaces at the end of each line.. Can someone please help me out.. I tried using sed command and its not working... can someone please help me out. (3 Replies)
Discussion started by: rammohan
3 Replies

4. Shell Programming and Scripting

Remove lines between the start string and end string including start and end string Python

Hi, I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

5. Shell Programming and Scripting

Remove lines that match string at end of column

I have this: 301205 0000030000041.49000000.00 2011111815505 908 301205 0000020000029.10000000.00 2011111815505 962 301205 0000010000027.56000000.00 2011111815505 3083 312291 ... (2 Replies)
Discussion started by: herot
2 Replies

6. Shell Programming and Scripting

remove spaces and lines that start with --

Is it possible to remove empty lines between >humid-sets (bold) and also humidset that start with -- (for ex: > humid3 | () : | (+) ) Thanx in advance Note: The humid sets will be in thousands and lines will be more than 100 thousand. input > humid1 | () : | (+)... (7 Replies)
Discussion started by: quincyjones
7 Replies

7. Shell Programming and Scripting

Remove the spaces at the end of a line starting from a fixed position

I want to remove the trailing spaces at the end of each line starting from a particular position(using ksh script). For example, in the attached file, I want to remove all the spaces starting from the position 430 till the end. The space has to be removed only from the 430th position no matter in... (3 Replies)
Discussion started by: Suryaaravindh
3 Replies

8. Shell Programming and Scripting

How to remove white spaces from the beginning an end of a string in unix?

Suppose, I have a variable var=" name is ". I want to remove the blank spaces from the begining and endonly, not from the entire string. So, that the variable/string looks like following var="name is". Please look after the issue. (3 Replies)
Discussion started by: mady135
3 Replies

9. Shell Programming and Scripting

append end of line with 8 spaces

child_amt=$amount prev_line="$prev_line $child_amt" i am getting the result like this 21234567890001343 000001004OLFXXX029100020091112 0000060 but i want 8 spaces between the eg: 21234567890001343 000001004OLFXXX029100020091112 0000060 how can i do this in .ksh (1 Reply)
Discussion started by: kshuser
1 Replies

10. UNIX for Dummies Questions & Answers

how to append spaces(say 10 spaces) at the end of each line based on the length of th

Hi, I have a problem where I need to append few spaces(say 10 spaces) for each line in a file whose length is say(100 chars) and others leave as it is. I tried to find the length of each line and then if the length is say 100 chars then tried to write those lines into another file and use a sed... (17 Replies)
Discussion started by: prathima
17 Replies
Login or Register to Ask a Question