|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Using awk !!!
Hello I have a line like this
Product Name: eserver xSeries 336 -[abcdefgh]- I'd like to get the string abcdefgh in shell using sed, awk or whatever else fits I tryed awk /\[/,/\]/p but it doesn't work. I tryed many things but awk or sed without any success. Any advice on how to do it ? |
|
#2
|
||||
|
||||
|
perl
, something likeperl -pe 's/\[(.+)\]/$1/;'
__________________
~James [Not currently seeking freelance work] Like philosophy or interested in spirituality? Philosophorum. Game Dev Experts Forums Foresight Linux - Because your desktop should be cool! Linux FAQ FedoraFAQ UbuntuGuide |
|
#3
|
|||
|
|||
|
Thanx, penguin but I'd like to know how to do it in shell.
|
|
#4
|
|||
|
|||
|
You can use sed to strip off everything up to and including the '[', and everything from the ']' to the end of line:
Code:
$ echo 'eserver xSeries 335 -[abcdefgh]-' | sed 's/.*\[//;s/\].*//' abcdefgh I think using ';' to separate two sed commands is undocumented - to be on the safe side you could put them on separate lines: Code:
$ echo 'eserver xSeries 335 -[abcdefgh]-' | sed 's/.*\[// s/\].*//' abcdefgh Dave |
|
#5
|
||||
|
||||
|
Quote:
You can build up a multiline script like that |
|
#6
|
|||
|
|||
|
Thanx you very much for this solution
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Other Programming Languages > Using awk !!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|