Issue
The following python requirement file defined more than 500 packages, and each package has a " ==
" and then the version
string.
# comment string
python_package_a == 1.2.3
# some text
python_package_b == 2.3.4
# test bar
hello == 0.1.2
# many other packages (more than 500 packages)
other_500_packages == x.y.z
I want to remove all versions from the requirement file by using bash sed
.
Here is the expected output:
# comment string
python_package_a ==
# some text
python_package_b ==
# test bar
hello ==
# many other packages (more than 500 packages)
other_500_packages ==
How to write the sed
command to remove just the "version" from all package lines?
Solution
I know how to use sed to search replace the entire line but I don't know how to keep all string before the "=="
You don't have to "keep", just match part of the line. Just match ==
and then the rest of the line. Then replace it with ==
.
sed 's/==.*/==/'
Answered By - KamilCuk Answer Checked By - Marilyn (WPSolving Volunteer)