I'm trying to create a script that will find/replace instances of a string matching:vc/integerThe file /etc/securetty contains the following strings:vc/1vc/2vc/3vc/4vc/5vc/6vc/7vc/8vc/9vc/10vc/11grep -E 'vc/(\d{0,4}\D)*' /etc/securetty | while read line; do sed -ie s=$line==g /etc/securetty; doneAs expected, the above command removes all the strings mentioned, but doesn't strip out the second digit, the 0 and the 1, which are a part of the last two strings, vc/10 vc/11. I'm left with a file containing01How can I modify the command to remove a single and double digit match?
piping grep regex into sed command
text processing;sed;grep
Why don't you just do this simply?sed -i -e 's|vc/[0-9]\{1,\}||g' /etc/securityExplanation:The regex [0-9]\{1,\} => 1 or more matches of the preceding atom, which in your case happens to be [0-9]. Note that \d+ although equivalent to what I've given [0-9]\{1,\}, is not POSIX sed compliant. In the same vein, note that [0-9]\{0,\}  is equivalent to \d*.