This ...
tail -2 test.txt | sed `|//g`
... should be:
tail -2 test.txt | sed 's/|//g'
That's probably what I would do. Note that not only is the sed expression in the original version incorrect, but the wrong kind of quotes are used as well. The wrong quotes are the reason for the "unknown command" error. They instruct the shell to execute |//g
as a command, and to insert its standard output into the sed
command line.
grep
does not offer a solution to the problem presented -- it allows you to filter lines based on whether they match a pattern, but it does not transform the contents of lines.
There is also tr
, however, which is mnemonic for "translate". This is to be understood as a character-level translation, not language translation. It can translate some characters to nothing. In particular:
tail -2 test.txt | tr -d '|'