Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1629  / 3 Years ago, sat, july 3, 2021, 8:42:47

I have a statement of the form atPhysAddress[1][1.10.0.0.98] i would like to remove all details except for the first one in the second bracket, or whichever value falls there, how can i achieve this?(i.e i would like to only leave out the first integer in the second bracket)


More From » sed

 Answers
2

For example with



$ echo "atPhysAddress[1][1.10.0.0.98]" | sed 's/([.*])[(.).*]/1[2]/'
atPhysAddress[1][1]


To only get the first number in the second bracket:



$ echo "atPhysAddress[1][12.10.0.0.98]" | sed 's/.*][([^.]*).*]/1/'
12

[#29352] Sunday, July 4, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fulerio

Total Points: 172
Total Questions: 124
Total Answers: 109

Location: Hungary
Member since Thu, Aug 6, 2020
4 Years ago
fulerio questions
;