I have a netlist file that contains some bitblasted signals. I want to change the signal name like below.

Its like


And I want it to be like


and I want this to be done only for particular set of signals, otherwise I would have just removed \ and ] and replaced [ with _.

How to do it only for particular list of signals? Can somebody help me on this?

  • 1
    Welcome to the site. Can you be more specific and describe which "particular set of signale" are to be changed? Please edit your question to include example input and the corresponding desired output. Also, please show us what you have already tried. – AdminBee Apr 27 at 7:55

Using the data in the question:

$ sed 's/\\\([[:alnum:]]*\)\[\([[:digit:]]*\)\]/\1_\2/g' file

The sed command matches the \word[digits] text, where word is any string of alphanumerical characters and where digits is a string of digits (these strings are allowed to be empty, change * to \{1,\} to require at least one character). The matching string is replaced by word_digits. The substitution is made for all matches across all lines in the data.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.