How to remove particular words from lines of a text file?

O.E

my text file looks like this:

Liquid penetration 95% mass (m) = 0.000205348
Liquid penetration 95% mass (m) = 0.000265725
Liquid penetration 95% mass (m) = 0.000322823
Liquid penetration 95% mass (m) = 0.000376445
Liquid penetration 95% mass (m) = 0.000425341

now I want to delete Liquid penetration 95% mass (m) from my lines to obtain the values only. How should I do it?

Zanna

If there's only one = sign, you could delete everything before and including = like this:

$ sed -r 's/.* = (.*)/\1/' file
0.000205348
0.000265725
0.000322823
0.000376445
0.000425341

If you want to change the original file, use the -i option after testing:

sed -ri 's/.* = (.*)/\1/' file

Notes

  • -r use ERE so we don't have to escape ( and )
  • s/old/new replace old with new
  • .* any number of any characters
  • (things) save things to backreference later with \1, \2, etc.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to remove particular words from lines of a text file?

From Dev

Remove particular lines from a text file in R

From Dev

How to remove lines from the text file containing specific words through terminal?

From Dev

How to remove lines from the text file containing specific words through terminal?

From Dev

How to remove specific lines from a text file?

From Dev

How to remove all instances of a particular symbol from a text file?

From Dev

How to remove words from text file in Python that contain certain letter?

From Dev

How to grep for lines which contain particular words in a log file?

From Dev

How to remove blank lines from text file using powershell

From Dev

Scala: How to remove blank lines when reading text from file

From Dev

How can I remove all lines not containing `@` from a text file?

From Dev

How to remove blank lines from text file using powershell

From Dev

How to remove duplicate lines from a large text file efficiently?

From Dev

How to remove first X lines from file up to the first occurrence of particular string?

From Dev

remove stop words from a text file

From Dev

Remove Repeated Words from Text file

From Dev

Remove words from a text file with Swift

From Dev

Remove Lines less than 3 words in a Text File

From Dev

Print sentences from text file that starts and ends with particular words or character?

From Dev

Remove lines from text file if it starts with

From Dev

Remove odd or even lines from a text file

From Dev

Remove lines from text file if it starts with

From Dev

Remove empty lines from a text file

From Dev

Pick up particular lines from a text file and calculate them together

From Dev

How to remove a place holder in a text file with text from another file when multiple lines are present?

From Dev

How to remove lines from output containing a particular string?

From Dev

How to remove lines from output containing a particular string?

From Dev

How to remove all alphanumeric words from the text?

From Dev

How to remove ALL stop words from text?

Related Related

  1. 1

    How to remove particular words from lines of a text file?

  2. 2

    Remove particular lines from a text file in R

  3. 3

    How to remove lines from the text file containing specific words through terminal?

  4. 4

    How to remove lines from the text file containing specific words through terminal?

  5. 5

    How to remove specific lines from a text file?

  6. 6

    How to remove all instances of a particular symbol from a text file?

  7. 7

    How to remove words from text file in Python that contain certain letter?

  8. 8

    How to grep for lines which contain particular words in a log file?

  9. 9

    How to remove blank lines from text file using powershell

  10. 10

    Scala: How to remove blank lines when reading text from file

  11. 11

    How can I remove all lines not containing `@` from a text file?

  12. 12

    How to remove blank lines from text file using powershell

  13. 13

    How to remove duplicate lines from a large text file efficiently?

  14. 14

    How to remove first X lines from file up to the first occurrence of particular string?

  15. 15

    remove stop words from a text file

  16. 16

    Remove Repeated Words from Text file

  17. 17

    Remove words from a text file with Swift

  18. 18

    Remove Lines less than 3 words in a Text File

  19. 19

    Print sentences from text file that starts and ends with particular words or character?

  20. 20

    Remove lines from text file if it starts with

  21. 21

    Remove odd or even lines from a text file

  22. 22

    Remove lines from text file if it starts with

  23. 23

    Remove empty lines from a text file

  24. 24

    Pick up particular lines from a text file and calculate them together

  25. 25

    How to remove a place holder in a text file with text from another file when multiple lines are present?

  26. 26

    How to remove lines from output containing a particular string?

  27. 27

    How to remove lines from output containing a particular string?

  28. 28

    How to remove all alphanumeric words from the text?

  29. 29

    How to remove ALL stop words from text?

HotTag

Archive