Ubuntu: error in sed command



Question:

I use below command for files previously and it works perfectly but now it generated below error or warning the desired output is list of 82 names but this code giving 88 i try to analyze the output file 95% of names are a/c to desired output but remaining few are not. (This code is basically to find the fileB [contains names only] in fileA [which contain names and its ids]):

while read -r line; do sed -n "/$line/,/^C/p" fileA| sed '$d';done<fileB>fileC   sed: -e expression #1, char 16: extra characters after command  


Solution:1

You must escape any special characters comming from your read line. E.g if the $line contains any characters like / \ " { } ... your sed expression falls apart.

See this post for some escaping magic: https://unix.stackexchange.com/a/33005


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »