How to remove a string from file in mac terminal

I have a file with million records and each line ends with SYSTEM;\N. I want to delete all occurrences of ;\N from file.

2 answers

  • answered 2017-08-16 19:25 raizsh

    You can use the sed command to replace all the occurrences of the ';\N' from the file and replace it with ''.

    sed -i 's/original/new/g' file.txt


    sed = Stream EDitor

    -i = in-place (i.e. save back to the original file)

    The command string: s = the substitute command

    original = a regular expression describing the word to replace (or just the word itself)

    new = the text to replace it with

    g = global (i.e. replace all and not just the first occurrence)

    file.txt = the file name

  • answered 2017-08-16 19:25 user842122

    This worked finally sed -i '' 's/;\\N//g' test112.csv