Sed + removes all leading and trailing spaces from each line of a Solaris system

I have a Solaris machine (SunOSsu1a 5.10 Generic_142900-15 sun 4vsparcSUNW, Netra-T2000).

The following sed syntax removes all leading and trailing spaces from each line (I need to remove spaces because this causes application problems).

        sed 's/^[ \t]*//;s/[ \t]*$//' orig_file > new_file

But I noticed that sed also removes the "t" character from the end of each line.

Please advise how to correct the syntax / command of sed to remove only leading and trailing spaces from each line (the solution can also be with Perl or AWK).

Examples (look at the last line - set_host)

1)

Original line before running sed command

   pack/configuration/param[14]/action:set_host

another example (before the launch of the sed)

   +/etc/cp/config/Network-Configuration/Network-Configuration.xml:/cp-pack/configuration/param[8]/action:set_host

2)

line after running sed command

   pack/configuration/param[14]/action:set_hos

another example (after running sed)

   +/etc/cp/config/Network-Configuration/Network-Configuration.xml:/cp-pack/configuration/param[8]/action:set_hos
+3
2

, :

sed 's/^[[:space:]]*//;s/[[:space:]]*$//'

sed gnu sed --posix, () posix [ \t] , \ t. , \t, - , , Ctrl + V Tab. , ( ) sed -f patterns.sed oldfile > newfile.

+5

@aix, , , , sed \t. GNU sed , Unix- . HP-UX - , , Solaris . GNU sed, Perl:

perl -pi.old -e 's{^\s+}{};s{\s+$}{}' file

... (^\s +) [ / ] (\ s + $), , "file.old".

0

All Articles