mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00

This PR is part of porting all old scripts #221 and includes a set of modules: - `data_extraction` - `examples` - `duplicates` ## 7 changed files: ### `data_extraction` - `data_extraction/ultimate_extractor.nu`: removed. Has already been ported to `modules/data_extraction/ultimate_extractor.nu` ### `duplicates` - `duplicates/duplicates.nu` -> `modules/duplicates/duplicates.nu` - `duplicates/example.nu` -> `modules/duplicates/example.nu` - `duplicates/README.md` -> `modules/duplicates/README.md`: unchanged ### `examples` - `examples/netstat.nu` -> `modules/examples/netstat.nu` - `examples/date_in_local_timezones.nu` -> `modules/examples/date_in_local_timezones.nu` - `befove_v0.60/assets/core_team.nu`: removed. This table has been embedded into `date_in_local_timezones.nu`
22 lines
724 B
Text
22 lines
724 B
Text
# duplicates returns the rows that correspond to duplicates of the given column.
|
|
export def duplicates [
|
|
column: string # Column to look duplicates at
|
|
--count(-c) # set it to display the number of times the value is repeated.
|
|
] {
|
|
group-by {get $column | into string} |
|
|
transpose |
|
|
insert count { $in.column1 | flatten | length } |
|
|
where count > 1 |
|
|
reject column0 |
|
|
if ($count | is-empty) { reject count } else { each { $in } } |
|
|
flatten |
|
|
flatten
|
|
}
|
|
|
|
# duplicates files recursively finds duplicate files in the current working folder.
|
|
# It uses a heuristic based on duplicate files having the same size.
|
|
export def "duplicates files" [] {
|
|
do -i {ls **/*} | duplicates size
|
|
}
|
|
|
|
|