如果有人能帮助我,我将非常感激。 我需要一个表单输出:
home/Documents/some-cool-doc
.docx
.html
.js
答案 0 :(得分:2)
试试这个:
ls -Xp | grep -Eo "\.[^/]+$" | uniq
答案 1 :(得分:0)
首先请务必使用associative array。
For each file in directory
store the filename,
append the file extension to the value
For each filename indexed
print the filename and associated extensions
#!/usr/bin/env bash
declare -A filenames
for file in *; do
filename="${file%.*}"
ext="${file##*.}"
printf "$filename . $ext\n"
filenames["$filename"]="${filenames["$filename"]}"$ext",";
done;
for filename in "${!filenames[@]}"; do
printf "$filename \n\t ${filenames["$filename"]}\n";
done
content-requirements-example
zip,
user-journey.pptx
zip,
Ergonomic-criteria-for-the-evaluation-of-human-computer-interfaces-J.M.-Christian-Bastien,-Dominique-L.-Scapin
pdf,
UX_Curve_templates_eng_new
doc,pdf,
可能有一些角落案例,随时可以适应。