Вы можете сохранить результат в переменной bash:
Go.java :
class Go {
private static String fld;
public static void main(String[] args) {
fld = args[0];
fld += fld.length();
System.out.println(fld);
}
}
run.sh
VALUE=test
while true
do
VALUE=`java Go $VALUE`
echo $VALUE
done
Вывод :
test4
test45
test456
test4567
test45678
Или сохранить результат в файл, прочитать его в bash и передать в качестве параметра в Go.java.
Вот хранилище файловпример:
Пример файла Go.java :
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
class Go {
private static String fld;
public static void main(String[] args) throws IOException {
fld = args[0];
fld += fld.length();
FileWriter fileWriter = new FileWriter("store.txt");
PrintWriter printWriter = new PrintWriter(fileWriter);
printWriter.print(fld);
printWriter.close();
}
}
Пример файла run.sh :
VALUE=store
while true
do
java Go $VALUE
VALUE=`cat ./store.txt`
echo $VALUE
done
Пример файла Вывод :
store5
store56
store567
store5678