#!/bin/bash for item in `ls collection_dir` do col=${item%%.*} echo $col newman run collection_dir/${item} --reporters cli,html,junit \ --environment dev.postman_environment.json \ --reporter-html-export ${col}-result.html \ --reporter-junit-export ${col}-result.xml done
其中${item%%.*}表示從右邊開始刪除,直到最後一個.號,好比demo.postman_collection.json,處理以後,變成demohtml
shell截取字符串的方法shell