I am tired of this sed :D So I have a small file:
version = "1.1"
group= "com.centurion.eye"
archivesBaseName = "eye"
impmet {
version = "4.1614"
runDir = "eclipse"
}
And here is my sed command:
sed -n -e '/version/ s/.* = *//p' "build.gradle"
And I need to get ONLY version 1.1. So when I execute this command, the output is:
"1.3"
"4.1614"
But desired one is:
"1.3"
How can I achieve that? Thanks!
Use sed 's insert ( i ) option which will insert the text in the preceding line.
It means that sed will read the next line and start processing it. nothing will be printed other than the blank lines, three times each. Save this answer.
Find and replace text within a file using sed command Use Stream EDitor (sed) as follows: sed -i 's/old-text/new-text/g' input.txt. The s is the substitute command of sed for find and replace. It tells sed to find all occurrences of 'old-text' and replace with 'new-text' in a file named input.txt.
Quit after matching the first one.
sed -n -e '/version/ {s/.* = *//p;q}' build.gradle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With