[英]How can I list files x to y in a directory (Bash)
這列出了目錄中的所有svg文件:
ls -1 *.svg
但是我怎么能說50到100 svg?
謝謝
嘗試:
ls -1 *.svg | awk "NR >= 50 && NR <= 100"
這有幫助嗎?
ls -1 *.svg | head -100 |tail -50
其他答案在這里工作得很好,但是我想我會提供一個純粹的bash-內置解決方案:
declare -i x=50 y=100 i=0;
for f in *.svg; do
((++i>y)) && break;
((i>=x)) && echo "$f";
done;
這里還是一條緊湊的單行:
declare -ix=50 y=100 i=0; for f in *.svg;do((++i>y))&&break;((i>=x))&&echo "$f";done
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.