unix - Can't extract pattern from filename -


getting errors following sed command:

echo 20130521_onepki_p107336_app.pfx | sed -e 's/_\([pp][0-9]+\)_/\1/' 

instead of returning p107336, returning full filenam 20130521_onepki_p107336_app.pfx.

any ideas why happening, , how can restrict output pattern like?

the captures should escaped parentheses , can use case-insensitive match i, also, replacing capture part captured part no changes made. 1 matches entire line , replaces captured pattern:

sed -e 's/.*_\([pp][0-9][0-9]*\)_.*/\1/' 

Comments

Popular posts from this blog

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

Android Gson.fromJson error -