Создание максимального значения из столбца, которое зависит от диапазона другого столбца

Из man find, версия man-страниц Ubuntu:

-L Follow symbolic links. When find examines or prints information about files, the information used shall be taken from the properties of the file to which the link points, not from the link itself (unless it is a broken symbolic link or find is unable to examine the file to which the link points). Use of this option implies -noleaf. If you later use the -P option, -noleaf will still be in effect. If -L is in effect and find discovers a symbolic link to a subdirectory during its search, the subdirectory pointed to by the symbolic link will be searched.

When the -L option is in effect, the -type predicate will always match against the type of the file that a symbolic link points to rather than the link itself (unless the symbolic link is broken). Using -L causes the -lname and -ilname predicates always to return false.

Итак, find -L /usr/hdp/2.6.3.0-235 -type f -name "*.jar" -exec cp {} /tmp/jar263 \;должно помочь. Обязательно прочитайте параметры в разделе-введите , как предложил roaima, если вы столкнетесь с каким-либо странным поведением, (find может вести себя немного иначе, например. OS X ).

2
24.03.2020, 14:39
3 ответа

Пользовательcsvsqlизcsvkit:

csvsql -HS -d' ' --query 'select max(a) from file where b<400' file

Для содержимого, разделенного табуляцией, используйте -tвместо -d' '

.

илиawk:

awk '
    $2<400 && $1>max1{max1=$1}
    $2>400 && $1>max2{max2=$1}
    END {printf "%s (second column value < 400)\n%s (second column value > 400)\n",max1,max2}
' file

Если столбец 1 может быть отрицательным, вы должны инициализировать max1и max2, потому что, если он не установлен, max1 равняется нулю для $1>max1.

5
28.04.2021, 23:19

Использование Миллера

$ mlr --nidx --repifs filter '$2 < 400' then stats1 -a max -f 1 data
35.713600

$ mlr --nidx --repifs filter '$2 > 400' then stats1 -a max -f 1 data
35.733700
2
28.04.2021, 23:19

Проверено, работает нормально

команда

awk 'BEGIN{sum=0}($2 < 400 && $1 > sum){sum=$1}END{print sum}' filename;awk 'BEGIN{sum=0}($2 > 400 && $1 > sum){sum=$1}END{print sum}' filename

выход

35.7136
35.7337
3
28.04.2021, 23:19

Теги

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