简体   繁体   中英

How to extract part of filename in a folder in Linux

I have list of Jars, around 20 in a folder with versions. (EG: abc.defg-hij-1.0.10.jar). I want write all these jar file names to a file by removing the version and extension. (Expected : abc.defg-hij).

I am using this command:

printf '%s\n' *.jar> /opt/Test_hemachandar/test_bin/remote.txt

This gives me list of all the jar file names to remote.txt file, where I want to remove the version and extension.

要删除版本和扩展名,您可以通过sed管道名称:

… | sed 's/[-0-9.]*jar$//' >/opt/Test_hemachandar/test_bin/remote.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM