#!/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