Anonymous Anonymous - 2 years ago 177
Bash Question

Shell Script - Get name of dynamically generated file

I'm very new to shell script and therefore I don't now very much about it.
I have an application, which creates a java file with a half unknown name, and now I try to write a script, which needs this name.

The known name of the file is

, the
part is unknown and could be nearly anything (btw it is mostly a version number with variable text parts).

Now I want to save
(without the
) in a variable for later use. I looked very much in the internet, but I can't find a solution.

Answer Source

If you need get file name without extension .jar. You can refer my bash script below:

# for loop all files in target directory that matched plugin-*.jar
for f in target/plugin-*.jar
    # print file name without extension .jar
    echo ${f%.*}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download