I have a file containing strings delimited by any of the following undesired characters:<>|<space>It looks like this:...  > Test Item|Test Item ...The above ... ellipses represent continuation. The file is comprised of only a single line.I would like to modify the file so that the strings are delimited instead with only a single <space> char. For example:... Test Item Test Item ...With sed I tried:sed -e 's/< >*| */|//g' filenameBut that returned the following error message:sed: 0602-404 Function s/<  *| */|//g cannot be parsed.What to do?
Unix bash Sed command Combination on one file
bash;ksh
If there is no chance that any of the characters <> | might occur within the data you wish to retain in your file, then almost definitely the most efficient solution is simply to transliterate them away entirely:tr '<>|' '   ' <infile |    ###translate all delimiter chars to spacestr -s ' '     >outfile      ###pipe results to second tr and squeeze spacessed may work for you as well, but if it does, it will almost definitely be slower in doing so. You should be careful when working w/ input files not based around \newline delimiters and using tools designed to handle \newline delimited data (such as sed and grep) because some implementations may collapse under buffer strain.Your issue is not (yet) that, though: rather you have submitted invalid syntax as a sed command. @Archemar has already commented on what it is, but here is why:A sed s///ubstitution is a command composed of three fields:the s command primitive followed by a delimiter (typically /)the regular expression pattern field followed by the same delimiterthe replacement field followed by the delimiter and optional flagsEither or both of the latter two may be zero-length for different reasons - and so s/// is (context-depending) acceptable syntax. This means that the sed parser must depend very heavily on the delimiter. In your command you specify too many fields - which is a syntax error, and is why your function cannot be parsed.If your implementation's sed can handle the single-line input and is POSIX-compatible, then this should work instead:sed 'y/<>|/   /;s/  */ /g' <infile >outfile...where the y primitive above is sed's own transliteration function.