I have the following line
result_0.01.dat resultFile
I would like to get and change just the (result_0.01) part to a different text which might include numbers. Preferably I would like this to be done using sed.
Thank you in advance.
I have the following line
result_0.01.dat resultFile
I would like to get and change just the (result_0.01) part to a different text which might include numbers. Preferably I would like this to be done using sed.
Thank you in advance.
echo "result_0.01.dat resultFile" | sed "s|.*.dat|someOtherText.dat|g"
what happens here in sed part is:
we substitude (s flag at the beginning of sed) we find everything till .dat. We replace that part with someOtherText. and we do it globally (g flag at the end)
If you want to replace strings in file: https://unix.stackexchange.com/questions/112023/how-can-i-replace-a-string-in-a-files
If you ant to rename files in folder: Using sed to mass rename files
$ line='result_0.01.dat resultFile'
$ echo "$line" | sed 's/result_0.01/different text which might include numbers/'
different text which might include numbers.dat resultFile