I have some files in the same directory (in UNIX filesystem) that looks like:
a.txt.name
b.xml.name
c.properties.name
a.txt.name2
b.xml.name2
c.properties.name2
How do I get the string before the name
or name2
part using some shell command?
ie. the a.txt
, b.xml
, c.properties
part?
$ basename a.txt.name .name
a.txt
$ file="a.txt.name"
$ file="${file%.*}"
$ echo "$file"
a.txt
If naming convention is always foo.bar.other , then this is simple enough:
ls * | cut -d. -f1,2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With