I need some help with sed
. I have tried to look for information to do this but I couldn't find any specific and people hardly provide an explanation of the provided solution so this makes difficult to understand how sed
works.
Basically I have files with the following format:
NAME_DIGITS_ddd-11s-21a-ds_DIGITS_DIGITS.xml
I want to copy the first DIGITS (e.g 00004574
), which is the string between the first and second underscores.
Any idea of how to do this?
Considering that the first digits could be 0
what can I do to delete them?
I would appreciate any example for these two cases and an explanation would be really welcome too.
I have achieved the opposite: delete the characters between first and second underscores with: sed s/_[^_]*_/_/
but cannot see how to do what I really need.
00001234
), or do you also want to remove leading zeros (e.g. leaving just1234
)? – Chris Davies Aug 20 '15 at 09:59sed
? – Chris Davies Aug 22 '15 at 17:05