I have a file which contains the data lines like below.I want to remove the tab spaces at the end of each line.I have tried with the command
.but it does not work.Can anyone help me on this?
Last edited by Don Cragun; 08-31-2015 at 04:58 AM..
Reason: Add CODE tags.
Well, seems to depend on the system that you use. It works for me as is on my linux system. On FreeBSD, this sed -r 's/[ ]+$//' file works, i.e. it uses the -r option to switch to EREs, and it needs an explicit <TAB> char inserted on the (bash) command line by Ctrl-V <TAB>.
In addition to what RudiC suggested, the following should work on most systems:
If you want to it on a Solaris/SunOS system, use /usr/xpg4/bin/sed instead of sed.
Note, however, that the sample input you supplied does not contain any trailing spaces or tabs on any of the lines.
Thanks both of you for answering my question. I am using PuTTY (which is a free implementation of Telnet and SSH for Windows and Unix platforms).
I have tried the commands which you both suggested but it did not work.I noticed one thing that when i use the commands
and
the tab spaces at the end of the lines containing 6 fields are removed but not at the end of the lines containing less than 6 fields.
I mean to say when i use the above commands the tab space at the end of the line below is removed
and the tab space remained same at the end for these lines
Can you please look into this once?
---------- Post updated at 04:53 AM ---------- Previous update was at 04:50 AM ----------
One more thing i would like to add here,as Don said there are no trailing spaces in my data lines.and there is 1 tab space and 1 blank between each fields which i want to keep it as it is.and only thing is i want to remove the tab spaces at the end of each line even though the lines contains 6 fields or less than 6 fields.
Can't possibly be. Both sed solutions look just for the end-of-line and do not consider the field count. Even if there are more than one <TAB> due to missing fields, they are matched by the + sign in the regex and thus removed.
Please make sure there's no DOS line terminator (shown as \r, ^M or 0x0D)!
How to catch a two word keyword which may contain a new line(may include spaces or tab) in it.
for example there is a file a.txt.
$more a.txt
create view
as
(select from
.........
..........
( select
....
(
select
......
..
select only no (((
number
( select
end (12 Replies)
Hello Everyone,
I need a help from experts of this community regarding one of the issue that I am facing with shell scripting.
My requirement is to append char's at the end of each line of a file. The char that will be appended is variable and will be passed through command line.
The... (20 Replies)
I'm trying to remove all of the empty lines at the end of a Tab delimited file. They have no data just tabs.
I've tried may things, here are a couple:
sed /^\t.\t/d File1 > File2
sed /^\t{44}/d File1 > File2
What am I missing? (9 Replies)
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)
Hi All,
I have a line like this
" field1;field2;field3 " (single space after and before double quotes).
Now i have to remove these single space . Kindly help me.
Thanks in advance (2 Replies)
Hello All,
I am trying to remove all tabspaces and all blankspaces from my file using sed & awk, but not getting proper code. Please help me out.
My file is like this (<b> means one blank space, <t> means one tab space)-
$ cat file
NARESH<b><b><b>KUMAR<t><t>PRADHAN... (3 Replies)
Hi All
I am having problem in substitution of any number of spaces, or a combination of space and tab in between strings in the lines of text file. Is there any way out in Perl? Please help me.
e.g.,
Say the input is in the following format:-
XX yyy zzz... (1 Reply)
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)
what can I use ??
In vi, I can use :set list <-- and see end of line $.. or use cat -A but I am wondering if there is command or program that allows me to see all the hidden characters( space, tab and etc)
Please help
thanks. (3 Replies)
Hi Friends,
Can any one help with this issue:
How to trim spaces for each line at the end,
Like I have a file in this format.
EMP1 SMITH 46373 5 STREET HOWARD 74636
EMP2 JONES 5454 { these are spaces ........}
EMP3 SMITH 46373 5 STREET HOWARD 74636
EMP4 JON 2554 { these are... (1 Reply)