Мой расчет по умолчанию преобразуется в целое число (KSH)

Сокращение полезности имеет компактную запись:

cut -d, -f2-7 <input-file>

производство:

column2,column3,column4,column5,column6,column7

Отвечая на комментарий @PlasmaBinturong :, я намеревался решить проблему с короткой последовательностью вызова :"... моя команда awk стала бы ужасно длинной...". Однако можно также найти коды, которые упорядочивают поля по желанию. Как бы мне ни нравились awk, perl, python, я часто находил полезным создание специальной утилиты для расширения возможностей стандартного *nix. Итак, вот отрывок из тестового скрипта s2, показывающий, что утилиты recut и аранжировки позволяют повторно -аранжировку и дублирование, а аранжировка также позволяет уменьшать диапазоны полей:

FILE=${1-data1}

# Utility functions: print-as-echo, print-line-with-visual-space.
pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }

pl " Input data file $FILE:"
head $FILE

pl " Results, cut:"
cut -d, -f2-7 $FILE

pl " Results, recut (modified as my-recut):"
my-recut -d "," 7,6,2-5 < $FILE

pl " Results, arrange:"
arrange -s "," -f 5,3-1,7,5,3-4,5 $FILE

получение результатов из этих версий:

OS, ker|rel, machine: Linux, 3.16.0-10-amd64, x86_64
Distribution        : Debian 8.11 (jessie) 
bash GNU bash 4.3.30
cut (GNU coreutils) 8.23
recut - ( local: RepRev 1.1, ~/bin/recut, 2010-06-10 )
arrange (local) 1.15

-----
 Input data file data1:
column1,column2,column3,column4,column5,column6,column7,column8

-----
 Results, cut:
column2,column3,column4,column5,column6,column7

-----
 Results, recut (modified as my-recut):
column7,column6,column2,column3,column4,column5

-----
 Results, arrange:
column5,column3,column2,column1,column7,column5,column3,column4,column5

My -recut — это небольшая модификация кода textutils recut, а Arrange — наша версия расширенной версии. Дополнительная информация:

recut   Process fields like cut, allow repetitions and re-ordering. (what)
Path    : ~/bin/recut
Version : - ( local: RepRev 1.1, ~/bin/recut, 2010-06-10 )
Length  : 56 lines
Type    : Perl script, ASCII text executable
Shebang : #!/usr/bin/perl
Home    : http://www1.cuni.cz/~obo/textutils/ (doc)
Modules : (for perl codes)
 Getopt::Long   2.42

arrange Arrange fields, like cut, but in user-specified order. (what)
Path    : ~/bin/arrange
Version : 1.15
Length  : 355 lines
Type    : Perl script, ASCII text executable
Shebang : #!/usr/bin/perl
Modules : (for perl codes)
 warnings       1.23
 strict 1.08
 Carp   1.3301
 Getopt::Euclid 0.4.5

С наилучшими пожеланиями... ура, дрл

0
25.08.2021, 00:32
0 ответов

Теги

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