Пробелы замены с вкладками в Linux

Это не предупреждение, обычно, просто предложение. Вы создаете зависимость от чего-то излишне.

предположим Вы позже решаете, что B не должен наследовать A. Если Вы последуете совету Resharper, то Вы не должны будете изменять ту строку кода.

92
задан Jonathan 14 September 2009 в 22:06
поделиться

3 ответа

Используйте программу undepand (1)


UNEXPAND(1)                      User Commands                     UNEXPAND(1)

NAME
       unexpand - convert spaces to tabs

SYNOPSIS
       unexpand [OPTION]... [FILE]...

DESCRIPTION
       Convert  blanks in each FILE to tabs, writing to standard output.  With
       no FILE, or when FILE is -, read standard input.

       Mandatory arguments to long options are  mandatory  for  short  options
       too.

       -a, --all
              convert all blanks, instead of just initial blanks

       --first-only
              convert only leading sequences of blanks (overrides -a)

       -t, --tabs=N
              have tabs N characters apart instead of 8 (enables -a)

       -t, --tabs=LIST
              use comma separated LIST of tab positions (enables -a)

       --help display this help and exit

       --version
              output version information and exit
. . .
STANDARDS
       The expand and unexpand utilities conform to IEEE Std 1003.1-2001
       (``POSIX.1'').
162
ответ дан 24 November 2019 в 06:26
поделиться

Я думаю, вы можете попробовать с awk

awk -v OFS="\t" '$1=$1' file1

или SED, если вы предпочитаете

sed 's/[:blank:]+/,/g' thefile.txt > the_modified_copy.txt

или даже tr

tr -s '\t' < thefile.txt | tr '\t' ' ' > the_modified_copy.txt

или упрощенную версию tr-решения, предложенного Сэмом Бисби

tr ' ' \\t < someFile > someFile
41
ответ дан 24 November 2019 в 06:26
поделиться

Использование Perl :

perl -p -i -e 's/ /\t/g' file.txt
10
ответ дан 24 November 2019 в 06:26
поделиться
Другие вопросы по тегам:

Похожие вопросы: