How to remove tab space and new line from a file using sed?

i am using the default sed package that comes with solaris.

What have you tried so far?

I'd use tr instead.

tr '\n' ' ' < input; tr '\t' ' ' < input

Point being that sed uses newlines as delimiters and thus has a hell of a time working with them.

this might help .. http://sed.sourceforge.net/sed1line.txt

1.Remove Tab space using SED:

 sed 's/\/t//g' filename 

2.Remove Newline using SED:

 sed 's/\/n//g' filename 

one thing i tried is sed 's/[tab]//g' myfile

[tab] -> cntrl + i in keyboard to get the tab space

of course tr does the work easily :slight_smile: but i want to how does sed does the same

Try this...

sed 's/\t//g' input_file?

And it is not /t or /n it is \n and \t

Which OS?
--ahamed

no it doesnt work..i am using solaris 10

Type <CTRL-v> <TAB> instead of \t.

1 Like

even sed s/[tab key]//g filename works..

but why i cant use /t /n characters in sed?

The tab key could have a 'special meaning' in your shell...

Thanks for correcting me Ahmed. The below one liners works for you.
1.Remove Tab space using SED:

sed 's/\t//g' filename

2.Remove Newline using SED:

 sed 's/\n//g' filename