I'm new to sed command. I was reading the build script for some source code and I found this for loop in it.
for x in '*.la'
do
sed -i -e 's|^\(libdir=.\).*\(/opt/toolchains\)|\1\2|' x
done
I'm not able to understand the function this for loop is doing. Can anyone help.
It's iterating over a series of files in the current directory ending with ".la" and for each file found, it's editing the contents using sed to convert lines of the form:
libdir=X[zero-or-more-chars]/opt/toolchains
(where X is any character) into lines of the form:
libdir=X/opt/toolchains.
In other words, it's removing the [zero-or-more-chars] part of those lines.
Actually, this looks buggy because I would expect the sed command to reference $x, not x. I have a feeling you lost the $ somehow in the copy/paste step (or perhaps it's simply a bug).