Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i am working on building and deploying artefact based on changed files in Github commit.

i am able to get changed files in latest commit in a json file and format is like below

common/modules/module1/one.txt
common/modules/module2/one.txt
common/modules/module1/api/two.txt

I am using GitHub Actions and want to extract list of modules which were changed in last commit, so in this case module1 and module2 should be my output.

modules name can be anything but the pattern would be /modules/ in file.

how can i extract these using shell ?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
4.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

Take the 3rd slash-separated field, then get the unique entries

... | awk -F/ '{print $3}' | sort -u

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...